[fpc-pascal] Re: Ido not understand UTF8 in Windows
JoshyFun
joshyfun at gmail.com
Sat Feb 20 17:23:48 CET 2010
Hello FPC-Pascal,
Saturday, February 20, 2010, 3:21:51 PM, you wrote:
MVC> I fail to see how this can be an FPC problem.
MVC> See
MVC> http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx
MVC> and
MVC> http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx
MVC> For an explanation. It states clearly that the number of bytes is returned.
MVC> If it does return the number of characters, then that is a bug in the Microsoft call,
MVC> not in FPC.
Yes, it states that lpNumberOfBytesWritten returns the amount of
written _bytes_ which clearly fails in this case, but also states that
if return value is non-zero no error happends :-? Rewritting using
plain WinAPI outputs:
------------------------------------------
code page UTF8 - 65001 en Windows
Length of string: 7
camiĆ³n
Retcode: TRUE Returned written bytes: 6
------------------------------------------
uses classes,windows;
var
s: ansistring;
OutputH: THandle;
retcode: LongBool;
writ: LongWord;
Begin
Writeln('code page UTF8 - 65001 en Windows');
OutputH := GetStdHandle(STD_OUTPUT_HANDLE);
s:='cami'+#$C3+#$B3+'n';
writeln('Length of string: ',Length(s));
retcode:=WriteFile(OutputH,s[1],Length(s),writ,nil);
writeln('');
writeln('Retcode: ',retcode,' Returned written bytes: ',writ);
End.
------------------------------------------
--
Best regards,
JoshyFun
More information about the fpc-pascal
mailing list