Reputation: 6051
I need to replace a literal UNICODE character with a "normal" character in a string:
HTMLString := StringReplace(HTMLString, '??', '->', [rfReplaceAll]);
But I cannot enter this Unicode character in the Delphi code editor because of the Delphi code editor not being able to display this Unicode character.
I can clearly see that the above Unicode character is inside the string because when I send the string with CodeSite I can see it in the CodeSite Live Viewer:
CodeSite.Send('HTMLString', HTMLString);
This is a screenshot from the CodeSite Live Viewer:
So how can I replace this Unicode character in the string?
Delphi: 10.1 Berlin
Upvotes: 0
Views: 2000
Reputation: 14928
Delphi IDE support Unicode
since V2009, just right click in the code editor go to File Format
then select UTF8
, and here is a simple sample to replace the unicode char:
procedure TForm1.FormCreate(Sender: TObject);
Var
S: Char;
Str: string;
begin
S:= chr($25b6); // Or S:= chr(9654);
Str:= S + 'Hi there' + S;
Caption:= Str + ' ---> ' + StringReplace(Str, S, '', [rfReplaceAll]);
end;
Among the many new features found in Delphi 2009 is the imbuing of Unicode throughout the product. The default string in Delphi is now a Unicode-based string. Since Delphi is largely built with Delphi, the IDE, the compiler, the RTL, and the VCL all are fully Unicode-enabled.
To read all the article: http://edn.embarcadero.com/article/38437
Upvotes: 3