How to: Manage Files with Encoding

To facilitate the display of your code in a particular language and on a particular platform, you can associate a particular character encoding with a file. Be aware of the following limitations for each encoding.

  • ANSI encoding allows only characters that are supported in the current code page, which limits international use.

  • Unicode encoding can be used for international characters. However, if you are using Visual SourceSafe 6.0 or earlier, you cannot use shared check out, difference checking or merging functionality because files with Unicode encoding are handled as binary files.

  • UTF8 encoding can be used for international characters. However, do not use UTF8 encoding with Visual SourceSafe 6.0 or earlier because changes are made to files during check in, check out, difference checking, and merging that can incorrectly handle or corrupt the content of files.

Visual SourceSafe 7.0 and later handle files with Unicode or UTF8 encoding correctly.

Opening Files

You can choose the editor you want to use to edit the file. The list of editors available when you are opening the file depends upon the type of file you are attempting to open or create.

To open a file in an editor that supports Unicode encoding

  1. On the File menu, choose Open and then select File.

  2. In the Open File dialog box, click the arrow adjacent to the Open button and click Open With.

  3. From the list in the Open With dialog box, select an editor with encoding support, such as XML Editor with Encoding.

  4. Click OK.

  5. In the Encoding dialog box, select the correct encoding from the Encoding drop-down list.

  6. Click OK.

Saving Files

You can also save your code with a Unicode encoding or a different code page to support various languages, such as Western European or Eastern European. You can associate a particular character encoding with a file to facilitate the display of your code in that language, as well as a line ending type to support a particular operating system. Also, some characters, when used in filenames, cannot be saved unless they are saved with Unicode encoding.

To save a file with a different encoding or line ending type

  1. On the File menu, click Advanced Save Options.

  2. In the Advanced Save Options dialog box, select the encoding you want from the Encodinglist.

  3. From the Line Endings list, select the type of line ending you want.

    Note

    If you save your file with Unicode encoding and use Visual SourceSafe version 6 or earlier, the file should be checked into Visual SourceSafe as a binary file. Visual SourceSafe version 6 and earlier do not support merging, or comparing and showing differences, between files that are saved as Unicode. Visual SourceSafe 7.0 and later versions can handle Unicode and UTF8 format files safely, and with full functionality.

See Also

Concepts

International Projects in Visual Studio

Reference

Encoding Dialog Box

Advanced Save Options Dialog Box

Save File As Dialog Box

Other Resources

Editing Text, Code, and Markup

Globalizing and Localizing Applications