[fpc-devel] Unicode resource strings
Anton Kavalenka
anton.k at tut.by
Mon Aug 20 14:32:22 CEST 2012
On 20.08.2012 14:03, Martin Schreiber wrote:
> On Monday 20 August 2012 12:37:24 Anton Kavalenka wrote:
>> Since the beginning of my FPC use I maintain the following FPC/Delphi
>> compatible code.
>>
> Does it work if the source has been compiled with -Fcutf8 on Windows? IIRC FPC
> converts the source utf8 constants to the system encoding before building the
> resource string tables. Another question is the encoding of the *.rst files
> we need in the MSEi18n tool.
>
> Martin
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
I use separate include files for resource strings in UTF-8 and in win1251.
{$ifdef FPC}
{$i resources-utf8.inc}
{$else}
{$i resources-cp1251.inc}
{$endif}
IIRC FPC does NOT convert resource strings into system encoding.
Besides my applications use FPC runtime to extract own resorcestrings
into external files (for translation).
procedure ExtractStringResources;
var
os:TFileStream;
begin
if not FileExists(DefLocalesPath) then CreateDir(DefLocalesPath);
os:=TFileStream.Create(DefLocalesPath+PathDelim+ExtractFileName(ParamStr(0))+'.fpcres',fmCreate);
try
SetResourceStrings(@DoSaveStringResource,os);
finally
os.Free;
end;
end;
function
DoSaveStringResource(Name,Value:AnsiString;Hash:Longint;arg:pointer):AnsiString;
var
os:TStream absolute arg;
begin
Result:='';
os.WriteBuffer(Hash,sizeof(Hash));
os.WriteAnsiString(Value);
end;
Resources from both Windows and Linux EXE are extracted in UTF-8 (not
win1251).
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20120820/77eeba1d/attachment.html>
More information about the fpc-devel
mailing list