如何将两个中文字节合并为一个中文字 如何将两个中文字节合并为一个中文字 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 两个中文字节只要放到一起,在中文字符集支持下,看到的就是中文啦。(一般都有中文字符集的吧)比如类似0xbac4这样的,就是中文 我要把richedit里的中文保存到txt文件里,但是保存后是乱码void CExeManager::OnSaveAns(CString filename) { // TODO: Add your control notification handler code here UpdateData(TRUE); CStdioFile file; CString str=""; int nLenth; file.Open(filename,CFile::modeCreate|CFile::modeWrite); //m_edit.SetWindowText(filename); //获得文本的行数 CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_EXE_ANS); int nCount = pEdit->GetLineCount(); char szLine[200]; for( int i=0;i<nCount;i++ ) { //第i行的长度 nLenth = pEdit->LineLength( pEdit->LineIndex( i ) ); pEdit->GetLine( i,szLine,nLenth ); for(int j=0;j<nLenth;j++) { char c = szLine[j]; //chinese if ( c < 0 || c > 255 ) { str=str+szLine[j]; j++; str=str+szLine[j]; } //english else { str = str + szLine[j]; } } str = str + "\r\n" ; } file.Seek(0,CFile::end); file.WriteString( str ); file.Close();} 中文字不是小于0,大于255啊,底下的错了,要//chineseif ( c < 0 || c > 255 ){ str=str+szLine[j]; j++; str=str+szLine[j];}应该改为unsigned t;t=c;if(t>=0xA0){ str=str+szLine[j]; j++; str=str+szLine[j];} 未发现什么错误。调试一下,szLine是中文么? 中文的字符是要大于0xa0小于0xff的。 保存的时候默认保存好象是2进制的所以看到的是乱码?如果转换成STRING型的 好象就可以看到学习中~~~ _com_error 用哪个成员函数返回错误所在的行? 动态编辑警报图标的问题 关于PostMessage的一个问题 SMTP 问题(535 Auth failed System Error) 送分问题,大鸟,小鸟,都来哦。 我想把剪贴板的内容复制到word中,我该给他发送什么消息,WM_PASTE不行。 求vc连接odbc数据源的例子(access数据库),一经得到全分奉上 为什么dll中的函数在主程序中调用时返值不正常? 关于VC 2010 排版的问题. 小小的问题,(设备环境的困惑) 怎么让控件不消失 字符串解析!
比如类似0xbac4这样的,就是中文
void CExeManager::OnSaveAns(CString filename)
{
// TODO: Add your control notification handler code here UpdateData(TRUE);
CStdioFile file;
CString str="";
int nLenth;
file.Open(filename,CFile::modeCreate|CFile::modeWrite); //m_edit.SetWindowText(filename); //获得文本的行数
CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_EXE_ANS);
int nCount = pEdit->GetLineCount(); char szLine[200];
for( int i=0;i<nCount;i++ )
{
//第i行的长度
nLenth = pEdit->LineLength( pEdit->LineIndex( i ) );
pEdit->GetLine( i,szLine,nLenth ); for(int j=0;j<nLenth;j++)
{
char c = szLine[j]; //chinese if ( c < 0 || c > 255 )
{
str=str+szLine[j];
j++;
str=str+szLine[j];
} //english
else
{
str = str + szLine[j];
}
} str = str + "\r\n" ;
}
file.Seek(0,CFile::end);
file.WriteString( str );
file.Close();
}
//chinese
if ( c < 0 || c > 255 )
{
str=str+szLine[j];
j++;
str=str+szLine[j];
}应该改为
unsigned t;
t=c;
if(t>=0xA0)
{
str=str+szLine[j];
j++;
str=str+szLine[j];
}
调试一下,szLine是中文么?
所以看到的是乱码?
如果转换成STRING型的
好象就可以看到
学习中~~~