Re: [Q] How can I repair file name with wrong encoding?
Re: [Q] How can I repair file name with wrong encoding?
- Subject: Re: [Q] How can I repair file name with wrong encoding?
- From: Jens Alfke <email@hidden>
- Date: Wed, 12 Mar 2008 22:42:08 -0700
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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden