Florian Klaempfl wrote:
Martin Schreiber schrieb:
On Sunday 02 March 2008 18.48:01 Daniël Mantione wrote:
Op Sun, 2 Mar 2008, schreef Florian Klaempfl:
What did I wrong?
I'am not sure how this could be made working just a remark: -Fcutf8
influences _only_ the interpretation of string constants when converting
them to unicode.
Right. Try to compile the (utf-8 encoded) file without specifying a code
page, this should result in the constants ending up in the resourcestring
without processing.
And now the widestring constants are broken, see attachment...
Did you utf-8 decode the string constants?
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
Inside our projects there are lots of WIdeStrings handling.
For Delphi/Kylix we use the following dirty hack (somewhat reworked
routine from Borland RTL):
This one is Widows implementation,
There is also linux implementation
function LoadResStringW(const pRec: PResStringRec): WideString;
var
hInst:cardinal;
Buffer: array [0..1023] of char;
begin
if pRec = nil then Exit;
if pRec^.Identifier < 64*1024 then
begin
hInst:=FindResourceHInstance(pRec^.Module^);
// try wide
if LoadStringW(hInst,pRec^.Identifier, @Buffer, SizeOf(Buffer))>0 then
Result:=PWideChar(@Buffer)
else // try narrow
if LoadString(hInst,pRec^.Identifier, @Buffer, SizeOf(Buffer))>0 then
Result:=PChar(@Buffer)
else
Result:='-lost-';
end
else
Result := PWideChar(pRec^.Identifier);
end;
To get the wide string from resource string by its identifier, we go the
following:
resourcestring
sWideStringID='Some string';
var
mw:WideString;
mw:=LoadresStringW(@sWideStringID)
Under FPC there is special implementation, but dirty hack does not work
all the time, since there is hard to determine - where was the resource
string
was implicitly decoded to current codepage. PRestringRec is boralnd
specific, under FPC it is PAnsiString;
function LoadResStringW(const pRec: PResStringRec): WideString;inline;
begin
if pRec=nil then
Result:=''
else
begin
{$ifdef LINUX}
Result:=PAnsiString(pRec)^;
{$else}
{$ifdef WindowsUnicodeSupport}
Result:=UTF8Decode(PAnsiString(pRec)^);
{$else}
Result:=PAnsiString(pRec)^;
{$endif}
{$endif}
end;
end;
{$ENDIF} // end platform-compiler dependent string loader
Please help -
How to implement that dirty hack.
Best regards,
Anton Kavalenka
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel