汉字区位码查询换算程序 CString str; ((CEdit*)GetDlgItem(IDC_EDIT1))->GetWindowText(str); USES_CONVERSION; char *pBuffer = W2A(str); int i = 0; while(pBuffer[i] != '\0') { TRACE(L"%d\n", pBuffer[i]); i ++; } //判断是否含有非中文字符 if(i != str.GetLength() * 2) { pBuffer = NULL; UpdateData(FALSE); ((CEdit*)GetDlgItem(IDC_EDIT1))->SetSel(-1); return; } UpdateData(TRUE); m_strDes = L""; i = 0; while(pBuffer[i] != '\0') { //生僻字用0000表示 if(256 + pBuffer[i] - 160 < 0 || pBuffer[i + 1] > 0) { m_strDes += str[i /2]; m_strDes += L"[0000] "; i += 2; continue; } CString strTemp; if(256 + pBuffer[i] - 160 < 10) strTemp.Format(L"0%d", 256 + pBuffer[i] - 160); else strTemp.Format(L"%d", 256 + pBuffer[i] - 160); if(i%2 == 0) { m_strDes += str[i/2]; m_strDes += L"["; } m_strDes += strTemp; if((i+1)%2 == 0) m_strDes += L"] "; if((i+1)%12 == 0) m_strDes += L"\r\n"; strTemp.ReleaseBuffer(); i ++; } pBuffer = NULL; UpdateData(FALSE); /2]; m_strDes += L"[0000] "; i += 2; continue; } CString strTemp; if(256 + pBuffer[i] - 160 < 10) strTemp.Format(L"0%d", 256 + pBuffer[i] - 160); else strTemp.Format(L"%d", 256 + pBuffer[i] - 160); if(i%2 == 0) { m_strDes += str[i/2]; m_strDes += L"["; } m_strDes += strTemp; if((i+1)%2 == 0) m_strDes += L"] "; if((i+1)%12 == 0) m_strDes += L"\r\n"; strTemp.ReleaseBuffer(); i ++; } pBuffer = NULL; UpdateData(FALSE);