Perforce Public Knowledge Base - Corrupted UTF16 file content
× PRODUCTS SOLUTIONS CUSTOMERS LEARN SUPPORT
Downloads Company Partners Careers Contact Free Trials
Menu Search
Perforce
Reset Search
 

 

Article

Corrupted UTF16 file content

« Go Back

Information

 
Problem

On Windows, after syncing "text" (Perforce file type) files containing utf16 encoding, the file in my workspace seems corrupted.

Solution

As the utf16 character encoding is a double byte character encoding and Perforce treats "text" files as single byte, you may encounter rendering or corruption issues in a Windows environment. Windows line endings are not correctly converted within the UTF16 character set for "text" files.  This corrupts the utf16 file content.

File revisions with utf16 content should always be submitted using the "utf16" file type (on add, Perforce will automatically detect utf16 files unless the user or a typemap rule overrides this behavior).

In order to fix your issue follow these steps:

  • Edit your workspace specification and change the value of the LineEnding field to "unix"
     
  • Force sync the file (no line ending conversion will be done)
     
  • Check that the workspace file is now rendered properly
     
  • Checkout the file(s), changing the file type to utf16 (change from "text" to "utf16")
     
  • Edit your workspace specification and change the value of the LineEnding field back to "local"
     
  • Submit a new revision of the file

Example:

p4 client bruno_ws
  LineEnd: unix
p4 sync -f myfile.txt
p4 edit -t utf16 myfile.txt
p4 client bruno_ws
  LineEnd: local
p4 submit -d "Fixing unicode file"

 

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255