Xcode 警告:指定的输入编码为 Unicode (UTF-8),但文件内容显示为 Unicode (UTF-16);视为 Unicode (UTF-16)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16504272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:22:42  来源:igfitidea点击:

Xcode warning: The specified input encoding is Unicode (UTF-8), but file contents appear to be Unicode (UTF-16); treating as Unicode (UTF-16)

xcodelocalizationwarningslocalizable.strings

提问by Nikolai Nagornyi

I create the .strings file by using genstringscommand. Output file of this command encoded with UTF-16, but when i add generated .strings file to my project and then bild, Xcode show warning:

我使用genstrings命令创建了 .strings 文件。此命令的输出文件使用 UTF-16 编码,但是当我将生成的 .strings 文件添加到我的项目然后 bild 时,Xcode 显示警告:

The specified input encoding is Unicode (UTF-8), but file contents appear to be Unicode (UTF-16); treating as Unicode (UTF-16).

指定的输入编码为 Unicode (UTF-8),但文件内容显示为 Unicode (UTF-16);视为 Unicode (UTF-16)。

I open .strings file in textEdit.app and resave it with UTF-16, but this haven't effect.

我在 textEdit.app 中打开 .strings 文件并用 UTF-16 重新保存它,但这没有效果。

Hot to fix this? Thaks!

热修复这个?谢谢!

回答by Martin R

I could not reproduce the problem, but the easiest solution is probably to select the strings file in Xcode and set the "Text Encoding" to "UTF-16" in the File inspector.

我无法重现该问题,但最简单的解决方案可能是在 Xcode 中选择字符串文件并在文件检查器中将“文本编码”设置为“UTF-16”。

enter image description here

在此处输入图片说明