I have always wanted it to sort it out. Unfortunately, I will be more lazy, so I will drag it now ~ I hope I can have a little help to everyone ~ --- A bird 2005.1.4 ----> Unicode Convert to 3-bit UTF-8 encoding code (Copy modification) CSTRING STRUNICODE; STRUNICODE = "A bird is a handsome pot"; int Ilen; wchar m_acp [200]; char m_utf [200]; Ilen = multibytetowidechar (CP_ACP, NULL, STRUNICODE, -1, M_ACP, 200); Ilen = Widechartomultibyte (CP_UTF8, NULL, M_ACP, -1, M_UTF, 2000, NULL, NULL); CSTRING ZC; Zc.Format ("% D", M_UTF); AFXMESSAGEBOX (zc); // m_UTF is the UTF8 encoding that converts the afterwards, replacing the 3 digits after the binary ----> 16 Enter unicode converted Chinese character code (Copy modification) char TranslateHex (CHAR HEX) {if (HEX> = 'a') Return (HEX & 0xDF) - 'A' 10; Else Return HEX - '0';} char * urlstr = "% B0% A1% C4% F1 % CA% C7% CB% A7% B9% F8 "; // A bird is handsome pot int Len = strlen (urlstr); char * result = new char [len 1]; MEMSET (Result, Len 1, 0 ); For (int i = 0, j = 0; i <= le; i , j ) {if (URL STR [i] == ' ') Result [j] = ''; else if (urlstr [i] == '%') {result [j] = translateHex (urlstr [i 1]) * 16 TranslateHex (URLSTR [i 2]); i = 2;} else result [j] = urlstr [i];} AFXMessageBox (Result); ----> UTF-8 Convert Unicode Chinese Character code (Copy Modification) CHAR STR [256] = {(CHAR) 0xE4, (CHAR) 0xBD, (CHAR) 0XA0, (CHAR) 0XE5, CHAR) 0XA5, (CHAR) 0XBD, (CHAR) 0X61, (CHAR) 0X62, (char) ) 0x63, (char) 0}; // segment UTF-8 encoding wchar * stra; int i =
MultibyToWideChar (CP_UTF8, 0, (Char *) STR, -1, NULL, 0); stra = new wchar [i]; multibytetowidechar (cp_utf8, 0, (char *) STR, -1, str, i); i = Widechartomultibyte (CP_ACP, 0, Stra, -1, NULL, 0, NULL, NULL); char * strb = new char [i]; widechartomultibyte (CP_ACP, 0, STRA, -1, STRB, I, NULL, NULL); // STRB is what AfxMessageBox (STRB); delete [] stra; delete [] strb;