Show quoted text 8 lines
Hi, I'm receiving from a Delphi 7 app a unicode Stream (from Synapse
library) containing Unicode data and I need to show it in a Lazarus
form. How can I convert it to look correctly on screen?.
Example:
The string "Leonardo Ram?" is shown as "Leonardo Ram\u009".
I had the same problem and use now the following function for decoding:
function DecodeUnicodeEscapes(EscapedString: String): String;
var
FoundPos: LongInt;
HexCode: String;
DecodedChars: String;
begin
Result := EscapedString;
FoundPos := Pos('\u', Result);
while (FoundPos 0) and (FoundPos < Length(Result) - 4) do begin
HexCode := Copy(Result, FoundPos + 2, 4);
DecodedChars := WideChar(Hex2Dec(HexCode));
Result := AnsiReplaceStr(Result, '\u' + HexCode,
UTF8Encode(DecodedChars));
FoundPos := Pos('\u', Result);
end;
end;
hth
Michael