我的CBXE IdFTP 出現亂碼
我的CBXE IdFTP 出現亂碼
請問怎麼解決?
[解决办法]
//我这里没有FTP服务器 无法测试 你用t2->DelimitedText = UTF8ToString(t1->Strings[i]) ;t2->DelimitedText = UTF8ToUnicodeString(t1->Strings[i]) ;//下面还有extern PACKAGE int __fastcall UnicodeToUtf8 [[deprecated]](char * Dest, WideChar * Source, int MaxBytes)/* overload */;extern PACKAGE unsigned __fastcall UnicodeToUtf8(char * Dest, unsigned MaxDestBytes, WideChar * Source, unsigned SourceChars)/* overload */;extern PACKAGE int __fastcall Utf8ToUnicode [[deprecated]](WideChar * Dest, char * Source, int MaxChars)/* overload */;extern PACKAGE unsigned __fastcall Utf8ToUnicode(WideChar * Dest, unsigned MaxDestChars, char * Source, unsigned SourceBytes)/* overload */;extern PACKAGE RawByteString __fastcall UTF8Encode(const WideString WS)/* overload */;extern PACKAGE RawByteString __fastcall UTF8Encode(const UnicodeString US)/* overload */;extern PACKAGE RawByteString __fastcall UTF8Encode(const RawByteString A)/* overload */;extern PACKAGE ShortString __fastcall UTF8EncodeToShortString(const WideString WS)/* overload */;extern PACKAGE ShortString __fastcall UTF8EncodeToShortString(const UnicodeString US)/* overload */;extern PACKAGE ShortString __fastcall UTF8EncodeToShortString(const RawByteString A)/* overload */;extern PACKAGE WideString __fastcall UTF8Decode [[deprecated("Use UTF8ToWideString or UTF8ToString")]](const RawByteString S);extern PACKAGE WideString __fastcall UTF8ToWideString(const RawByteString S);extern PACKAGE UnicodeString __fastcall UTF8ToUnicodeString(const RawByteString S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToUnicodeString(const char * S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToUnicodeString(const ShortString &S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToString(const RawByteString S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToString(const ShortString &S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToString(const char * S)/* overload */;extern PACKAGE UnicodeString __fastcall UTF8ToString(char const *S, const int S_Size)/* overload */;extern PACKAGE RawByteString __fastcall AnsiToUtf8(const UnicodeString S);extern PACKAGE UnicodeString __fastcall Utf8ToAnsi(const RawByteString S);extern PACKAGE UnicodeString __fastcall LoadResString(PResStringRec ResStringRec);extern PACKAGE PUCS4Char __fastcall PUCS4Chars(const UCS4String S);extern PACKAGE UCS4String __fastcall WideStringToUCS4String(const WideString S);extern PACKAGE WideString __fastcall UCS4StringToWideString(const UCS4String S);
[解决办法]
OnConnect
void __fastcall xxx::IdFTP1Connect(TObject * ASender)
{
IdFTP1->IOHandler->DefTextEncoding = TEncoding::Default;
}
估计轮到我只有1分了,真没劲!
[解决办法]
使用网络截包工具看一看,服务器传回的列表是什么内容,大致可以分析出FTP服务器是什么编码,然后采用相应的编码器。
IdFTP1->IOHandler->DefStringEncoding = TEncoding::Default;
IdFTP1->IOHandler->DefStringEncoding = TEncoding::UTF8;
IdFTP1->IOHandler->DefStringEncoding = TEncoding::Unicode;
都可以试试,
使用这个 TEncoding::Default 时,必须是服务器与客户端相同的操作系统语言,楼主是用繁体字,若服务器是简体汉字,就可能有问题了(中文字)。FTP服务器也太多了,问题也很多。
在简体中文操作系统时,TEncoding::Default 也许就是 GB2313
在繁体中文操作系统时,TEncoding::Default 也许就是 BIG5