Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have string which is Unicode and I want to convert to UTF-8 to show on RichEditcontrol as it supports UTF8 only. iam able to convert everything but only currency symbols like euro or rupees is coming as garbage etc

here is the string before conversion:

The bid of ₹ 29 is to be paid

after conversion:

The bid of ₹ 29 ( currency is only giving issue)

Please help me out in this.

What I have tried:

CStringA strUtf8 = CW2A(strTemp, CP_UTF8);

or


PSTR Utf8;
DWORD Length;
INT ReturnedLength;

//// A utf8 representation shouldn't be longer than 4 times the size
//// of the utf16 one.
Length = WideLength * 4;

if (!Utf8)
{
/* TODO: handle failure */
}

DWORD WideLength = _tcslen(strRTF) + 1;
Utf8 = (PSTR)malloc(WideLength * 4);

ReturnedLength = WideCharToMultiByte(CP_UTF8,
0,
WideString,
-1,
Utf8,
Length - 1,
NULL,
NULL);

if ( ReturnedLength )
{
// Need to zero terminate...
Utf8[ReturnedLength] = '\0';
}
else
{
/* TODO: handle failure */
}
free(Utf8);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900