views:

909

answers:

6

Where can I set it? I need files to be encoded in UTF-8 by default... there is nothing in Tools -> Options or any other menu as far as I know :(

P.S. I don't need to set default encoding for Project or so, I need it to be default for any files I create. Thanks for your help :)

A: 

IIRC, source files in visual studio are already encoded as UTF-8.

However, if I'm wrong or if you just want to force any specific coding, you can do it by choosing the Save As... option for the file and checking the pull down options under the save button from there.

Joel Coehoorn
+1  A: 

I believe you cannot set the source encoding as a project setting. Instead, it tries to determine the source encoding from the file, using a fairly limited algorithm. Part of that algorithm is

  • if it has an UTF-8 signature (BOM), it is UTF-8 encoded
  • otherwise, it is in the ANSI system code page (CP_ACP)

There might be some additional checks in-between (e.g. checking for UTF-16 with BOM also).

In my experience, the "save as" encoding is not very useful, unless saving as UTF-8-with-BOM. You can save it in a different encoding, but in reopening, it will still assume it's CP_ACP.

Martin v. Löwis
A: 

Thank you for your answers but that's not exactly what I need.

Ok I will try to be more specific. That's how it goes: I go to Open website, I open website directly via FTP. On the right hand side I can see file list. I right-click on it, choose new item, html file, I have new html file. I add some text into it, click save (CTRL+S), the file is saved. Now I open it via browser and I see it's not saved in UTF-8. So, can I fix this problem in any way? :)

Sejanus
+1  A: 

Instead of clicking save click save as. Then click the little down arrow by save to save with encoding. Once this is done it will bring you to the advanced save options which appear in full VS studio. You can then pick UTF-8 as the encoding.

Dean
+1  A: 

File -> Advanced save options

Choose Encoding and Line endings

Regards, Haris

hcusto
A: 

are you saying that even though the source file is encoded in utf-8, your internet browser is displaying it as ansi? do you have a meta encoding tag defined?

http://tlt.its.psu.edu/suggestions/international/web/tips/declare.html

try this and your browser should say it is utf-8. just saving a file in utf-8 won't do it.

marduk