Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
746 views
in Technique[技术] by (71.8m points)

iphone - How to change text encoding of Localizable.strings file in Xcode 4?

I am learning how to localize the strings in my project and I am using Xcode 4.

I have generated the base Localizable.strings file, and I want to import this file, changing its encoding from utf-16 to Unicode utf-16 so that the text in the file is readable within xCode. If I strate import this file, when I select it within xcode, the text shows up as gibberish.

In Xcode 3 when you drag the Localizable.strings into your project, the dialog box which appears gives you the option to change the text encoding, but this is not the case in Xcode 4.

Does anyone know a way around this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Maybe this can help you Objective C/Xcode 4: Encoding Problem with Localizable.strings files

These kind of errors can happen if you copy and paste content within Xcode or from external files in your localization files. The consequence is that the encoding of the file changes to for example Western (Mac OS Roman). The Localizable.strings file should be in UTF-16 though.

Solution

1. Like in the picture below, navigate in Xcode to the Localizable.strings location and open it so that you can see all the languages you are supporting.

Localizable.strings

  1. Left-click on the language file the causes the build error.

  2. Make sure your Utilities View is showing in Xcode. Activate on the button at mark 1 in Picture below.

XCode Utilities

  1. In the Utilities View select the File Inspector. (Small Logo that looks like Page)

  2. Under Text Settings change the encoding to UTF-16(Marked as 2 in the picture above). The Drop-Down might be grayed out but you can click on it anyways. Click on "Convert" on the Popup.

That's it your project should now compile again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...