I'm playing around with SynEdit and I've found an issue I had to fix in the code of SynEdit, here it is:
First. If the loaded file is invalid UTF8, UTF8Decode function returns empty string. Personally I believe it is better to provide user with wrong encoded file, than no file at all. The best solution I've found so far was to use alternative function, from Delphi Fundamentals library. It requires cUnicodeCodecs unit ( http://fundementals.sourceforge.net/unicode.html ). The changes in SynUnicode are following: in function LoadFromStream, find
Code: Select all
{$IFDEF UNICODE}
UnicodeStrings.Text := UTF8ToUnicodeString(UTF8Str);
{$ELSE}
UnicodeStrings.Text := UTF8Decode(UTF8Str);
UnicodeStrings.SaveUnicode := True;
{$ENDIF}
Code: Select all
UnicodeStrings.Text := UTF8Decode(UTF8Str)
Code: Select all
UnicodeStrings.Text := UTF8StringToWideString(Utf8Str);