Use MFC to write a program, access to FTP path, FTP server Settings for utf-8 character encoding, I use CFtpFileFind class the following getfilename () to obtain the file name under the directory (in Chinese), then use the MultiByteToWideChar utf-8 characters into Unicode, but found that part of the Chinese to turn around, the right can be part of this show for the question mark in Chinese,,, ask the great spirit guide
CodePudding user response:
CFtpFileFind finder (m_pFtpConnection); Cstrings strFileName=_T (" "); StrFileName=finder. GetFileName (); USES_CONVERSION; Char * pFileName=T2A (strFileName); CharArrayToCString (pFileName strFileName, CP_UTF8); Void CSelFtpDirDlg: : CharArrayToCString (const char * pChar, CString& STR, int encodeType) { If (pChar!=NULL) { Size_t len=strlen (pChar); Size_t wcharCount=(size_t) MultiByteToWideChar (encodeType, 0, pChar (const char *), len, NULL, 0). USES_CONVERSION; WCHAR * szTemp=new WCHAR [wcharCount + 1]; SzTemp [wcharCount]=0; MultiByteToWideChar (encodeType, 0, pChar (const char *), (int) len, szTemp, (int) wcharCount); Char * pmtStr=W2A (szTemp); STR=(cstrings pmtStr); STR=STR. Left (len); The delete [] szTemp; } } CodePudding user response:
This part of the main code as above
CodePudding user response:
Everybody look bai, thanks a lot!
CodePudding user response:
STR=STR. Left (len); Why is this? Blocked see
CodePudding user response:
reference 4 floor zgl7903 response: STR=STR. Left (len); Why is this? Blocked see here to write the redundant, whar directly cstrings, problems should be appeared in the getfilename () here, then get the value of the UTF8 encoding and not complete CodePudding user response:
Can use multi-byte compile, only MultiByteToWideChar (CP_UTF8 a transition to the UNICODE characters should be ok for the I see online are sending OPTS UTF8 OFF command processing CodePudding user response:
refer to 6th floor zgl7903 response: can use multi-byte compile, only MultiByteToWideChar (CP_UTF8 once converted to UNICODE characters should be ok for the I see online are sending OPTS UTF8 OFF command processing I also tried to use multi-byte way before compilation, the result is the same, because is the FTP server on Linux, required UTF8, I finally it is no use MFC CFileFind class, the reasons for this problem should be getfilename return UTF8 encoding content have a problem here CodePudding user response:
Before I met, many bytes into utf-8, if not directly using a MultiByteTOWideChar went, the converted also needs a WideCharToMultiByte conversion to utf-8, as is the case,