How can I convert garbled filenames (Chinese) to the correct codepage?
-
On disk sometimes I have filenames that show up like ûÓÐÈË¿ÉÒÔ½ÐÄ㱦±´. However it should really be this: 没有人可以叫你宝贝. (Others are displayed correctly, so it is not a problem of the system). I can copy the garbaged filename to a text file, open it in a browser, change the codepage to gb2312 for display in the browser, copy the displayed Chinese characters and rename the file. (I currently do not see through what the browser does) This is not applicable for more than a few files. So I want to automate it. (I have a european Windows XP environment, should be the same with English) Is there any tool, that does it? Or how can I do what the browser can do by C# coding? (the encoding part is sufficient). Tried the encoding class but did not get any usable result. Please help. Thanks.
-
On disk sometimes I have filenames that show up like ûÓÐÈË¿ÉÒÔ½ÐÄ㱦±´. However it should really be this: 没有人可以叫你宝贝. (Others are displayed correctly, so it is not a problem of the system). I can copy the garbaged filename to a text file, open it in a browser, change the codepage to gb2312 for display in the browser, copy the displayed Chinese characters and rename the file. (I currently do not see through what the browser does) This is not applicable for more than a few files. So I want to automate it. (I have a european Windows XP environment, should be the same with English) Is there any tool, that does it? Or how can I do what the browser can do by C# coding? (the encoding part is sufficient). Tried the encoding class but did not get any usable result. Please help. Thanks.
That's interesting. I'm not sure what the problem is though. Just created a file named 没有人可以叫你宝贝.txt on a German XP (hope it doesn't mean anything nasty), and in Explorer it shows up as a sequence of squares. This looks like a system thing indeed, cause the file name is correct (as I can see when I drag it into Firefox, which shows 没有人可以叫你宝贝.txt in the address bar). Is this the phenomenon you mean, or do your files also have a different name? And if so, can you reproduce it?
-
That's interesting. I'm not sure what the problem is though. Just created a file named 没有人可以叫你宝贝.txt on a German XP (hope it doesn't mean anything nasty), and in Explorer it shows up as a sequence of squares. This looks like a system thing indeed, cause the file name is correct (as I can see when I drag it into Firefox, which shows 没有人可以叫你宝贝.txt in the address bar). Is this the phenomenon you mean, or do your files also have a different name? And if so, can you reproduce it?
Did you install your Windows' option "support for East Asian languages"? If so the filename should display as I have posted before. If you are using Tools instead of the Windows Explorer, it might be that they are not able to display double byte characters and will display symbols instead. Total Commander should work with it but some of its functions do not.
-
Did you install your Windows' option "support for East Asian languages"? If so the filename should display as I have posted before. If you are using Tools instead of the Windows Explorer, it might be that they are not able to display double byte characters and will display symbols instead. Total Commander should work with it but some of its functions do not.
No, I have no support for Asiian languages installed. Anyway, if it's actually about encoding, did you try something like this:
string source = "ûÓÐÈË¿ÉÒÔ½ÐÄ㱦±´";
Encoding sourceEncoding = Encoding.Default;
byte[] bytes = sourceEncoding.GetBytes(source);Encoding targetEncoding = Encoding.GetEncoding("gb2312");
string target = targetEncoding.GetString(bytes); -
No, I have no support for Asiian languages installed. Anyway, if it's actually about encoding, did you try something like this:
string source = "ûÓÐÈË¿ÉÒÔ½ÐÄ㱦±´";
Encoding sourceEncoding = Encoding.Default;
byte[] bytes = sourceEncoding.GetBytes(source);Encoding targetEncoding = Encoding.GetEncoding("gb2312");
string target = targetEncoding.GetString(bytes);