[英]How to keep BOM from removal from Perforce unicode files
I have converted entire branch with .NET and SQL sources to UTF-8 with BOM , having their Perforce file type changed to Unicode in the same operation. 我已经将带有.NET和SQL源的整个分支转换为带有BOM的UTF-8,在同一操作中将Perforce文件类型更改为Unicode 。 (Encoding difference might sound confusing, but in Perforce, Unicode file type denotes UTF-8 file content.) But later I have found out that Perforce silently elliminates BOM marker from UTF-8 files. (编码差异可能听起来令人困惑,但在Perforce中, Unicode文件类型表示UTF-8文件内容。)但后来我发现Perforce默默地从UTF-8文件中消除了BOM标记。 Is it possible to set Perforce to keep UTF-8 BOM markers in files of Unicode file type? 是否可以设置Perforce以将UTF-8 BOM标记保存在Unicode文件类型的文件中? I can't find it documented. 我找不到记录。
Perforce server is switched to Unicode mode, connection encoding is UTF-8 no BOM (but changing it to UTF-8 with BOM doesn't make any difference). Perforce服务器切换到Unicode模式,连接编码是UTF-8没有BOM(但将其更改为带有BOM的UTF-8没有任何区别)。
Example: 例:
OK, Hans Passant's comment encouraged me to re-examine P4CHARSET and finally, the answer has two parts: 好吧,Hans Passant的评论鼓励我重新审视P4CHARSET,最后,答案分为两部分:
For Perforce command line access , setting of P4CHARSET
variable controls the behavior. 对于Perforce命令行访问 , P4CHARSET
变量的设置控制行为。 To enable adding BOM to files of Unicode type, use command 要启用将BOM添加到Unicode类型的文件,请使用命令
p4 set P4CHARSET=utf8-bom
In order to have these files without BOM, use 为了使这些文件没有 BOM,请使用
p4 set P4CHARSET=utf8
For P4V The Perforce Visual Client , the setting can be changed via menu Connection
> Choose Character Encoding...
. 对于P4V Perforce Visual Client ,可以通过菜单Connection
> Choose Character Encoding...
更改设置。 Use value Unicode (UTF-8)
to enable adding BOM and Unicode (UTF-8, no BOM)
to suppress it. 使用值Unicode (UTF-8)
可以添加BOM和Unicode (UTF-8, no BOM)
来抑制它。
Choose Character Encoding...
is disabled, ensure the following (and then check again) 如果菜单项Choose Character Encoding...
被禁用,请确保以下(然后再次检查)
Notes: 笔记:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.