Xcode 中的“将 Unicode 字符视为空格”/“源文件中的无效字符”警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29445481/
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 06:55:14  来源:igfitidea点击:

"Treating Unicode character as whitespace"/"Invalid character in source file" warning in Xcode

xcode

提问by Tamás Sengel

When typing a spacecharacter in Xcode, a warning appears sometimes:

space在 Xcode 中输入字符时,有时会出现警告:

Treating Unicode character as whitespace

将 Unicode 字符视为空格

or

或者

Invalid character in source file

源文件中的无效字符

If I re-write the character, the warning disappears. What causes this?

如果我重新编写字符,警告就会消失。这是什么原因造成的?

回答by Tamás Sengel

That happens to me when I type too fast and accidentally hold down Altwhile pressing down Space. This creates a non-breaking space (0xA0) which is not recognized as a valid space character by Xcode.

当我打字太快并Alt在按下时不小心按住时会发生这种情况Space。这会创建一个不间断的空格 ( 0xA0),Xcode 不会将其识别为有效的空格字符。

For a (hacky) solution, I've remapped this combination to Insert Tabinside Xcode's Preferences/Key Bindings, so it enters a tabulator character instead.

对于(hacky)解决方案,我已将此组合重新映射到Xcode 的Preferences/Key Bindings 中的Insert Tab,因此它输入了制表符字符。