[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
Retcode: TRUE Returned written bytes: 6

uses classes,windows;
 s: ansistring;
 OutputH: THandle;
 retcode: LongBool;
 writ: LongWord;
 Writeln('code page UTF8 - 65001 en Windows');
 OutputH :=  GetStdHandle(STD_OUTPUT_HANDLE);
 writeln('Length of string: ',Length(s));
 writeln('Retcode: ',retcode,' Returned written bytes: ',writ);

Best regards,

More information about the fpc-pascal mailing list