MultiByteWideChar and € (Euro sign)
C / C++ / MFC
2
Posts
2
Posters
1
Views
1
Watching
-
The following string encoded in UTF8 "s in €" appears in ascii as "s in €" after a call to MutiByteToWideChar
int nSize = MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,NULL,0); if ( nSize == 0 ) return; WCHAR \* pBuffer= new WCHAR\[nSize\]; MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,pBuffer,nSize);
unfortunately instead of the Euro sign, I get the character #26 Any idea? Thanks
-
The following string encoded in UTF8 "s in €" appears in ascii as "s in €" after a call to MutiByteToWideChar
int nSize = MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,NULL,0); if ( nSize == 0 ) return; WCHAR \* pBuffer= new WCHAR\[nSize\]; MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,pBuffer,nSize);
unfortunately instead of the Euro sign, I get the character #26 Any idea? Thanks
Do you check the utf8 values in pstrValue are correct? Correct utf8 value for Euro sign is "0xe2, 0x82, 0xac". Also, if you check the pBuffer using C runtime function like printf, you should set locale properly before calling printf through setlocale function. I test your code but it runs correctly.