{
CString szDes = _T("");
int nlen = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)szSrc, -1, NULL, 0 );
wchar_t* pUnicode = new wchar_t[ nlen ];
char* pUtf8 = new char[ szSrc.GetLength() * 3 + 1 ];
memset( pUnicode, 0x00, nlen * 2 );
memset( pUtf8, 0x00, szSrc.GetLength() * 3 + 1 );
// SJIS 仺 Unicode
MultiByteToWideChar(
CP_ACP,
0,
(LPCSTR)szSrc,
-1,
pUnicode,
nlen );
// Unicode 仺 UTF8
nlen = WideCharToMultiByte( CP_UTF8, 0, pUnicode, -1, NULL, 0, NULL, NULL );
WideCharToMultiByte(
CP_UTF8,
0,
pUnicode,
-1,
pUtf8,
nlen,
NULL,
NULL );
szDes = CString(pUtf8);
delete[] pUnicode;
delete[] pUtf8;
return szDes;
}
for(int i=0; i<szString.GetLength(); i++)
{
unsigned char c1 = szString[ i ];
if( c1 < 0x80 )
{
continue;
}
else if( c1 == 0x8e )
{
szString.Delete(i, 1);
}
else
{
EUC→JIS
unsigned char c2 = szString[ i+1 ];
c1 = c1 - 0x80;
c2 = c2 - 0x80;
if (c1 & 0x01)
{
c1 = ((c1 + 1) / 2) + 0x70;
c2 = c2 + 0x1F;
}
else
{
c1 = (c1 / 2) + 0x70;
c2 = c2 + 0x7D;
}
if (c1 >= 0xA0) { c1 = c1 + 0x40; }
if (c2 >= 0x7F) { c2 = c2 + 0x01; }
//write back
szString.SetAt(i++, c1);
szString.SetAt(i, c2);
}
}