Skip navigation.
 
mlRe: [Q] How can I repair file name with wrong encoding?
FROM : Jens Alfke
DATE : Thu Mar 13 06:42:08 2008

On 12 Mar '08, at 9:40 PM, S.J.Chun wrote:

> For example, a file in zip archive from Windows(Korean), the file name
> will have CP949 encoding. If I unzip this file the file name looks 
> weird as
> you already expected. How can I repair the name of file?


That depends on what the un-zip program did. It sounds like it read 
the filename from the zip archive using the wrong encoding. I would 
guess that the most likely encoding it used was CP-1252, aka WinLatin, 
a superset of ISO-Latin-1. In other words, it read the bytes of the 
filename in the archive, used a CP-1252 decoder to convert them into 
Unicode characters, and then converted those to UTF-8 to pass to the 
Mac filesystem APIs.

So to fix this you'd need to do the reverse: Read the filename, 
convert to Unicode if necessary (already done for you if you're using 
Foundation APIs that return NSStrings), then encode the Unicode into 
CP-1252. Now you have the original bytes as they were in the zip 
archive. Decode them using CP949, and use the resulting Unicode as the 
new filename.

—Jens

Related mailsAuthorDate
ml[Q] How can I repair file name with wrong encoding? S.J.Chun Mar 13, 05:40
mlRe: [Q] How can I repair file name with wrong encoding? Kyle Sluder Mar 13, 06:10
mlRe: Re: [Q] How can I repair file name with wrong encoding? S.J.Chun Mar 13, 06:27
mlRe: [Q] How can I repair file name with wrong encoding? Jens Alfke Mar 13, 06:42
mlRe: [Q] How can I repair file name with wrong encoding? Jens Alfke Mar 13, 15:48
mlRe: [Q] How can I repair file name with wrong encoding? Aki Inoue Mar 13, 22:52
mlRe: [Q] How can I repair file name with wrong encoding? John Stiles Mar 13, 22:56