Udostępnij za pośrednictwem


How to: Manage Files By Using 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 on 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, click Open and then click File.

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

  3. On the list in the Open With dialog box, select an editor that has 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 by using 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, and also a line-ending type to support a particular operating system. Also, some characters, when they are used in file names, cannot be saved unless they are saved by using Unicode encoding.

To save a file by using a different encoding or line-ending type

  1. On the File menu, click Save As.

  2. In the Save File As dialog box, click the arrow adjacent to the Save button and then click Save with Encoding.

  3. In the Advanced Save Options dialog box, on the Encoding list, select the encoding you want.

  4. On the Line Endings list, select the kind of line ending you want.

    Note

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

See Also

Reference

General, Text Editor, Options Dialog Box

Concepts

International Projects in Visual Studio

Other Resources

Editing Text, Code, and Markup

Globalizing and Localizing Applications