0

我使用此函数从 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 字符。

谢谢您的帮助。

4

0 回答 0