You are not logged in.
Hi,
so I have this problem, I need to print some 'regional' characters. They're handled incorrectly.
System character set is windows-1250.
Regular Canvas.Textout handles these characters correctly.
Here's the screenshot (left - Edit1 on the left, report on the right)
and the code
DrawText('direct ' + Edit1.Text);
DrawText('utf8ToString' + UTF8ToString(Edit1.Text));
DrawText('StringToUTF8' + StringToUTF8(Edit1.Text));
yeah, I know those conversions doesn't make sense but I just wanted to try everything before asking for help
Offline
Which version of Delphi are you using?
What are the "regional" characters?
Which text alignment are you using here?
Can you step in TGDIPages.InternalUnicodeString() then guess what GetACP() return?
Offline
Delphi7 ... Regional characters - ą ę ś ć ź ł ń ó ż
GetACP returns 1250.
TextAlign := taLeft; just before printing the sting.
Offline
In the method, could you step into those lines:
{$ifndef USEPDFPRINTER}
if GetACP<>1252 then begin
{$endif}
// low-level MBCS RTL function including last widechar #0
StringToWideChar(s,PW,PWLen*2+1);
PWLen := lstrlenW(PW);
{$ifndef USEPDFPRINTER}
end else
// fast WinAnsi conversion using a fixed table from SynCommons
for i := 0 to PWLen do // includes S[length(s)+1]=#0 -> last widechar #0
PWordArray(PW)[i] := WinAnsiTable[PByteArray(s)[i]];
{$endif}
{$endif}
And see what's inside the PW buffer after the call to StringToWideChar?
Offline
Offline
So the Delphi function is wrong and doesn't seem to get the right code page...
Could you change the StringToWideChar lines with this:
{$ifndef USEPDFPRINTER}
if GetACP<>1252 then begin
{$endif}
// low-level MBCS RTL function including last widechar #0
PWLen := MultiByteToWideChar(GetACP, 0, Pointer(s), Length(s), PW, PWLen);
PW[PWLen] := #0;
{$ifndef USEPDFPRINTER}
end else
Offline
MultiByteToWideChar method solved the problem Thank you!
Offline