如题,
比如俄文的 “и ” 如何得到UTF码“\xd8”
在线等各位解答~帅哥等你啊~~
比如俄文的 “и ” 如何得到UTF码“\xd8”
在线等各位解答~帅哥等你啊~~
解决方案 »
- 如何把子对话框中的数据显示在主对话框中的ListCtrl中?
- MFC数据库程序如何在其他电脑上运行
- 头疼啊,moving in memory, 64bit DLL的秘密?
- win32 sdk如何响应做为子控件的listbox中右键消息?
- 一个关于窗口的问题
- 大家帮我看一下这个问题!在线等
- 那位侠客知道 pcanywhere 的模块是怎么一回事?
- 新手提问:可不可以用ATL建立一个对话框,
- 关于在CStatic的图片框内画线图时其它画面遮住时会吧画上去的线图擦掉应如何解决。
- 50分求《C++ 大学教程》(最好是发到我的e-mail:[email protected])。提供线索者也给分。
- 用DirectDraw创建带有Alpha通道的Suface???
- MFC在Dialog中添加菜单问题
* name : BSTRToUtf8
* description: 字符集转换: BSTR - UTF8
* input : bstrSrc:要转化的BSTR字符串;
* output : NA
* return : 转化后的UTF8字符集编码的字符串
* re : NA
***********************************************************************************/
string NS_CBB::BSTRToUtf8 ( const BSTR& bstrSrc )
{
/*!< 获得目标空间的大小 */
int iAllocSize = WideCharToMultiByte ( CP_UTF8, 0, bstrSrc, -1, NULL, NULL, NULL, FALSE ) - 1;
if ( 0 >= iAllocSize )
{
return "";
}
/*!< 返回值 */
string strRet( iAllocSize, '\0' ); /*!< 进行转换 */
int nResult = WideCharToMultiByte ( CP_UTF8, 0, bstrSrc, -1, const_cast<char*>( strRet.c_str() ),
iAllocSize, NULL, FALSE ); return strRet;
}
{
/*!< 分配目标空间, 一个16位Unicode字符最多可以转为4个字节 */
//int iAllocSize = static_cast<int>( wstrSrc.size() * 4 + 10 ); int iSize = static_cast<int>( wstrSrc.size() );
int iAllocSize = WideCharToMultiByte ( CP_UTF8, 0, wstrSrc.c_str(), iSize + 1, NULL, NULL,NULL,NULL ); char* pszBuffer = new char[ iAllocSize ];
if ( NULL == pszBuffer )
{
return "";
}
ZeroMemory(pszBuffer, iAllocSize*sizeof(char));
int iCharsRet = WideCharToMultiByte( CP_UTF8, 0, wstrSrc.c_str(),
static_cast<int>( wstrSrc.size() ),
pszBuffer, iAllocSize, NULL, NULL );
/*!< 成功 */
string strRet;
if ( 0 < iCharsRet )
{
strRet.assign ( pszBuffer, static_cast<size_t>( iCharsRet ) );
} /*!< 释放内存 */
delete[] pszBuffer; return strRet;
}wstring CToolsHelp::CStringToUTF8Hex( CString cstrSrc)
{
wstring wstrTemp = __C(cstrSrc);
string strAnsi = UnicodeToUtf8( wstrTemp ); return AnsiToUnicode(StrToHex( strAnsi));
}
#include <fstream.h>
#include <stdio.h>
#include <afx.h>
#include <Rus_string.h>
#include <windef.h>main()
{
CFile fp;
fp.Open(_T("e:\\1.txt"),CFile::modeWrite|CFile::modeCreate);
fp.SeekToBegin();
fp.Write("\xef\xbb\xbf",3);
const char* gstr_MenuTitleRus[] =
{
"\6Главное меню", /* 0 */
"\6ручной поиск", /* 1 */
"\6системные установки", /* 2 */
"\6Настройки ТВ", /* 3*/
"\6установка меню", /* 4 */
"\6Родитесльский контроль", /* 5 */
"\6редакдировать программы", /* 6 */
"\6Список программы", /* 7*/
"\6состояние ресивера", /* 8 */
"\6Списокпоиск",
"\6Сканирование канала",
"\6УСТАНОВКА ВРЕМЕНИ",
"Language Set", /* 12 */
};for(int i=0;i<=13;i++)
{
typedef unsigned long DWORD;
DWORD wcsLen= MultiByteToWideChar(CP_ACP,NULL,gstr_MenuTitleRus[i],-1,NULL,0);
wchar_t*wszString=new wchar_t[wcsLen+1];
MultiByteToWideChar(CP_ACP,NULL,gstr_MenuTitleRus[i],-1,wszString,wcsLen);
wszString[wcsLen]='\0';int u8Len= WideCharToMultiByte(CP_UTF8,NULL,wszString,wcslen(wszString),NULL,0,NULL,NULL);
char*szU8=new char[u8Len+1];
WideCharToMultiByte(CP_UTF8,NULL,wszString,wcslen(wszString),szU8,u8Len,NULL,NULL);
szU8[u8Len]='\0';fp.Write(szU8,u8Len*sizeof(char));fp.Flush();
}
fp.Close();
delete[] szU8;
return 0;
}
很不规范,就是想问下怎么得到UTF-8的解码。。