-[Danny Chen]- Blog of an ASP.NET QA tester

Tips and info about Site Navigation, ImageMap, Menu and other cool ASP.NET v2.0 features.

Saving unicode content with encoding

Here's a quick tip that you may or may not know about.  In Visual Studio (and possibly other MS programs) it's not enough to paste some unicode content into your file and then hit save.  You'll also need to save it with the correct encoding.  However, once you save the file with a particular encoding, it will continue to use that encoding until you switch it (this means you won't have to keep doing this for each save)

Here are the steps to do this: 

simple choose file->save as
in the save-as dialog the "Save" button has a little pull down arrow.
Select this arrow and then choose "Save With Encoding"
This will open a dialog with a drop down that lists all the supported encodings.

Here are some screenshot to help out:

 

Comments

Gilles said:

Near the bottom of that list we also have:
Unicode (UTF-8 <b>without</b> signature) - Codepage 65001

What could be the impact of choosing between <b>with</b> or <b>without</b> signature?

Thanks for any information!
# February 26, 2006 1:14 PM

Danny Chen said:

Gilles -
Actually that is a really good question, I'm not sure what the answer is. In reality, this dialog and the list of encodings all comes from Windows or atleast the .NET framework team (not ASP.NET).
# March 1, 2006 1:12 PM

Erjan said:

The with encoding option is useful for use with some systems, which need the UTF87 signature (the three byts in the beginning of the file) to handle the characters correctly. For example, a javascript (.js) file, saved as UTF8 without signature, operating on strings might sometimes output some A-like characters instead of swedish characters.

In addition to Danny's post: If you open the respective core Visual Studio 2003 files (like C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\CSharpProjectItems\JScript.js, C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddWebUserControl\Templates\1033\WebUserControl.ascx, etc and save them as unicode, you will have your newly added files encoded. You will not need to convert every single file to unicode (or whatever) encoding.
# March 11, 2006 4:36 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)