I'm learning ruby and try to get the filename from a ftp server. The string I got was encoded in *gb2312(simplified Chinese)*, It's success in most cases with these codes: str = str.force_encoding("gb2312") str = str.encode("utf-8") but it will make an error "in encode': "\xFD" followed by "\x88" on GB2312 (Encoding::InvalidByteSequenceError)" if the string contains the symbol "[" or "【". Then I use force_encoding("gb2312").valid_encoding? to detect if all filename strings were encoded by gb2312, some of them return false. I think I must deal with a string list that's in mixed character encodings. Help me! Thank you!
on 2013-11-06 08:30