Hi + tx for support!
I am unsure where to convert. I have a TWebDataSet with a field DESCRIPTION. Within the TwebDBGrid the sonderzeichen are displayed ok. But when I want to add the text to a Word doc using paragraph.AddText(cdsRezept.FieldByName('bezeichnung').AsString) the < is output as <.
What do I have to do, to get the original text in the Word doc, too?
Addition:
I am translating descriptions, that otiginally contain "<" and the translation returns this as <. However, in the grid this is displayed as <, but the word component renders this unchanged as <.
Am I supposed to HTMLDecode all text?
I tried to do this:
uses
WR.Datasets.JSON, System.NetEncoding;
function HTMLDecode(s:string):String;
begin
result:=TNetEncoding.HTML.Decode(s);
end;
Unfortunately this does not compile:
[Fehler] WR.Utils.pas(97): identifier not found "HTML"
How do you get from TWebDataSet (I assume TWebClientDataSet?) to Word?
Also, what is WR.Utils.pas, WR.Datasets.JSON, .. these are not TMS WEB Core units.
Also, TNetEncoding.HTML is at this moment not a part of the pas2js RTL, so it can't be used in TMS WEB Core.
You could use this function to do the conversion:
function DecodeHTMLEntities(const AStr: string): string;
var
TextArea: TJSHTMLTextAreaElement;
begin
TextArea := TJSHTMLTextAreaElement(Document.createElement('textarea'));
TextArea.innerHTML := AStr;
Result := TextArea.value;
end;
This is how I add the text to Word:
The WR.* are some of my own units.
Tx for the function.
Is it planned, that Word substitutes the encodings?
I assume from this single line of code that you use TMS FNC WX Pack's docx generator component?
We will investigate & consider for a future update.
Yes, Bruno, it is TMS FNC WX Pack's docx .
function DecodeHTMLEntities(const AStr: string): string;
var
TextArea: TJSHTMLTextAreaElement;
begin
TextArea := TJSHTMLTextAreaElement(Document.createElement('textarea'));
TextArea.innerHTML := AStr;
Result := TextArea.value;
end;
What units must I use, to get this compiled?
Yes, I thought so, but the IDE underlines thsi as an unknown identifier, so I was unsure. However, the compile succeeds.
Thank you!