MessageBoxW / Memo / TEdit显示UNICODE字符

时间:2012-05-28 01:49:08

标签: delphi unicode utf-8 delphi-7

我使用此函数从RCDATA资源中读取UTF-8编码数据:

function ReadResourceW(ResourceName : WideString): WideString; // for UTF-8 and RCDATA
 var
  ServerModule: HMODULE;
  ResourceLocation: HRSRC;
  ResourceSize: dword;
  ResourceHandle: THandle;
  ResourcePointer: pointer;
  PBufferString : AnsiString;
 begin
  ServerModule := LoadLibraryW(NIL);
  try
   ResourceLocation := FindResourceW(ServerModule,PWideChar(ResourceName),PWideChar(10)); // For RCDATA
   ResourceSize := SizeofResource(ServerModule, ResourceLocation);
   ResourceHandle := LoadResource(ServerModule, ResourceLocation);
   ResourcePointer := LockResource(ResourceHandle);
   if ResourcePointer <> nil then begin
    SetLength (PBufferString, ResourceSize);
    CopyMemory(@PBufferString[1], ResourcePointer, ResourceSize);
    Delete (PBufferString,1, 3); // Delete the EF_BB_BF
    result := UTF8Decode(PBufferString);
    FreeResource(ResourceHandle);
    end;
   finally
    FreeLibrary(ServerModule);
   end;
 end;

之后我使用MessageBoxW来显示UNICODE字符。 在某些角色(如笑脸,心脏等)上,消息框仅显示正方形。 除了我有Delphi7的TNTComponents和所有unicode字符显示为'|'在备忘录或编辑中。有没有办法可以在消息框或备忘录/编辑/等中“绘制”所有unicode字符。

感谢您的帮助。

0 个答案:

没有答案