|
-
December 17th, 2010, 03:11 PM
#1
Is it possible to use WideCharToMultiByte with Letterlike Symbols [like "™"]?
Help!
I need to send a string over internet from a Windows [client side] system to a UNIX [server side] ...
In the client side I have a std::wstring data and I "translate" this data to an UTF-8 std::string before send it to avoid problems in server side. To do that, I´m using WideCharToMultiByte func [http://msdn.microsoft.com/en-us/libr...v=vs.85).aspx].
However, I´m facing a problem to send "Skype ™ 4.2.2". The following error is launched in server side:
"... a wide character has been encountered that can not be represented as a multibyte sequence (according to the current locale) [Skypeâ
¢ 4.1] : [Invalid or incomplete multibyte or wide cha ..."
I wrote a sample code to illustrate what I´m trying to do:
void main()
{
std::wstring wide = L"Skype ™ 4.2.2";
std::string normal = "";
char codePgBuf[4096];
wchar_t wcodePgBuf[4096];
if (WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, codePgBuf, sizeof(codePgBuf), NULL, NULL) == 0)
printf("WC2MB failed for %u : '%S", GetLastError(), wide.c_str());
normal = codePgBuf;
FILE *pFile;
pFile = fopen("test.txt", "w");
if (pFile!=NULL)
{
fputs(normal.c_str(), pFile);
fclose (pFile);
}
}
The result of this program is an file [test.txt] with this content:
Skype â„¢ 4.2.2
*** is going on? What am I doing wrong? Any guess? 
Is it possible to use WideCharToMultiByte with Letterlike Symbols?
Many thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|