Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BOM issue in unicode perforce server

Tags:

perforce

Steps to repro the issue:

  1. Add a file to my P4 server, the file is detected as 'utf8' file type.

    The file I added is utf8 encoding without BOM. The file I added is utf8 encoding without BOM.

    nobomb show in vim

    nobomb show in vim

p4 client detect it as 'utf8' p4 client detect it as 'utf8'

If I do the same steps on other device, the file type is detected as 'unicode';

  1. Delete the file from local, and then sync it from server. issue occur: the file become utf8 with BOM.

sync the file, the file become utf with BOM sync the file, the file become utf with BOM

As you know, BOM in html file can cause lots of issue....Is there anyone who can help me to solve this issue?

Environment:

  1. Client version: Rev. Perforce Visual Client/MACOSX107X86_64/2015.2/1312139

  2. p4 server is in "unicode" mode.

  3. P4CHARSET of the workstation is set to utf8. enter image description here
like image 540
Leon Avatar asked Feb 13 '26 11:02

Leon


1 Answers

Files of type 'utf8' always sync with the BOM - 'utf8' type is designed that way (see relnotes, #998379). If you don't want the BOM you're going to have to change it to 'text' or 'unicode'.

What you describe is a known bug(job083614) in your 15.2: "if P4CHARSET=utf8 and server is unicode and file has bytes >x80 and is valid utf8" then file is detected as utf8, should be unicode. This fix should hopefully (no promises) be in 16.2.

Earlier p4 clients <= 15.1 should detect it as 'unicode'.

If you don't want type 'utf8' but rather 'unicode':

  • add your file with "p4 add -t unicode <file>"
  • change the file's type before submitting.
  • use typemap to make all files with certain extension add as 'unicode'.
  • use a client (p4v, p4 command line) <= 2015.1 to add the files. Subsequent syncs/submits can be later versions.

You can also have a trigger to prevent utf8 file types from being submitted(change-submit)

like image 113
J Brown Avatar answered Feb 17 '26 10:02

J Brown