I am having problems displaying Unicode characters incorrectly in my user interface. I only have a resource library containing a string table used to localize the user interface. I create a DLL in Delphi XE3 using a DLL project (it just has {$R 'lang.res' 'lang.rc'} in the DPR file and gives me lang.dll ). I confirmed that my lang.rc file is in UTF-8 format with Windows CRLF line breaks. When I load strings from a DLL, Unicode characters mix with the interface. Here are a few details.
Excerpt from the row table:
STRINGTABLE { 59,"180Λ" 60,"90Λ CW" 61,"90Λ CCW" }
Here are the code snippets that illustrate the problem that I am encountering with Unicode characters:
Here is my Delphi function used to load strings from a resource library:
class function TLangHelper.LoadStr(ResourceId: Integer):String; var Buff: String; L: Integer; begin Result := ''; if LangDllHandle = 0 then begin LangDllHandle := LoadLibrary(LANGUAGE_DLL_LOCATION); if LangDllHandle = 0 then begin ShowMessage('Error loading language localization resources.'); end; end; if LangDllHandle <> 0 then begin L := 1024; SetLength(Buff, L+1); LoadString(LangDllHandle, ResourceId, PChar(Buff), L); Result := String(PChar(Buff)); end; end;
Any suggestions?
FOLLOW-UP:
For Chinese characters, I had to add the previous L to the line definitions in the .rc file so that the DLL compilation would recognize them as Unicode. For example (English, Chinese Traditional, Chinese Simplified, French):
STRINGTABLE { 35,"Status Bar" 1035,L"ηζ
ζ¬" 2035,L"ηΆζζ " 3035,"Barre d'Γ©tat" }
source share