How to keep BOM from removal from Perforce unicode files

本小妞迷上赌 提交于 2019-12-05 19:51:46

OK, Hans Passant's comment encouraged me to re-examine P4CHARSET and finally, the answer has two parts:


For Perforce command line access, setting of P4CHARSET variable controls the behavior. To enable adding BOM to files of Unicode type, use command

p4 set P4CHARSET=utf8-bom

In order to have these files without BOM, use

p4 set P4CHARSET=utf8

For P4V The Perforce Visual Client, the setting can be changed via menu Connection > Choose Character Encoding.... Use value Unicode (UTF-8) to enable adding BOM and Unicode (UTF-8, no BOM) to suppress it.

  • if menu item Choose Character Encoding... is disabled, ensure the following (and then check again)
    • P4V has connection to server open and working
    • pane containing depot/workspace tree is focused (click inside to re-ensure this)

Notes:

  • if you usually combine both above ways to access Perforce, you need to apply both solutions, otherwise you will keep getting mixed results
  • if you want to instantly add/remove BOM to/from existing files, adjust the above settings, then remove files from workspace and add them again (see steps 5 and 6 of example posted in the question). Other server actions changing content of files (integrating, merging etc.) will do the similar
  • for other encoding options and their impact on BOM, see the second table in Internationalization Notes for P4D, the Perforce Server and Perforce client applications
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!