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. (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. Is it possible to set Perforce to keep UTF-8 BOM markers in files of Unicode file type? 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).
Example:
- check out a source file from Perforce
- change file type to Unicode
- convert file content to format "UTF-8 with BOM"
- submit the file (now the file still keeps BOM in first 3 bytes)
- remove the file from workspace
- get the latest revision of the file (now the file doesn't contain BOM at the beginning)
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 commandIn order to have these files without BOM, use
For P4V The Perforce Visual Client, the setting can be changed via menu
Connection
>Choose Character Encoding...
. Use valueUnicode (UTF-8)
to enable adding BOM andUnicode (UTF-8, no BOM)
to suppress it.Choose Character Encoding...
is disabled, ensure the following (and then check again)Notes: