Discussion:
Error 87 using WideCharToMultiByte and UTF8
(too old to reply)
Peter
2007-07-05 16:03:41 UTC
Permalink
Using BCB5

I try to convert a unicode string to MBCS using the UTF8 page code.
Function: WideCharToMultiByte()
But the funtion fails with 0 and GetLastError() reports error 87

Now I use this code for years now, without problems, using the ANSI
installed (CP_ACP) code page, but I never used CP_UTF8 before

In fact, my BCB5 Help file doesn't mention the code page: CP_UTF8, I got it
from MSDN:
http://msdn2.microsoft.com/en-us/library/ms776420.aspx

Could it be that my BCB5 is not able yet to do this ?
Peter
2007-07-05 16:29:30 UTC
Permalink
Post by Peter
I try to convert a unicode string to MBCS using the UTF8 page code.
Function: WideCharToMultiByte()
But the funtion fails with 0 and GetLastError() reports error 87
Now I use this code for years now, without problems, using the ANSI
installed (CP_ACP) code page, but I never used CP_UTF8 before
In fact, my BCB5 Help file doesn't mention the code page: CP_UTF8, I got
http://msdn2.microsoft.com/en-us/library/ms776420.aspx
Could it be that my BCB5 is not able yet to do this ?
Oops !!!!
Found it.
I had overlooked this sentence:
"With this value set, lpDefaultChar and lpUsedDefaultChar must be set to
null pointers"
And that was indeed the problem.

I tested and the output was nicely UTF8
Only to find out afterwards that bloody printf apparently understands UTF8
and changes the 2 characters for a special character into the proper
character.
So I can't output a UTF8 string that way.

Loading...