开发者

How can I convert a UTF-16 encoded string to an encoding suitable for a Mac OS X filename?

I have a Localized.strings (UTF-16) file that contains some strings that I use to gen开发者_运维知识库erate filenames for. I open the file in python with codecs.open("Localized.strings", "r", "utf-16")

The files are created successfully but with a '?' tacked onto the end of the filename, for example:

MainMenu.strings? - where the "?" is lingering from the previous encoding I assume.

I've tried filename_string.encode('UTF-8') and filename_string.encode('ascii') with no luck, any suggestions? Am I using these wrong?


OK, when reading lines from a file, it's advisable to always strip() or rstrip() them. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜