views:

1138

answers:

2

I'm working on an open source project. The original project contains comments in russian and is using codepage 1251. I'm using codepage 1252 and the russian comments aren't displayed correctly in Visual Studio Express 2008, not nice but anyway I can't read russian. Someone using codepage 950 (traditional chinese) tried to compile the project and was unable to do it, because of the code page! Now it is really annoying.

I think that using unicode (and more exactly UTF-8 with signature) as file format for the code source is the way to go.

Problem: how to convert the whole source code easily?

I have already though about:

  • Let Visual Studio save the source code as UTF-8. But: My computer is using codepage 1252 and I found no way to tell VS that the original code source is using codepage 1251 so that the conversion won't be correct.

    Edit: As pointed by "LicenseQ" there is a way to open a single file in VS with another encoding: click Arrow near Open button in open dialog, chose "Open With" and then chose "Code Editor (with encoding)".

  • Of course I could change the codepage of my computer for the time of the conversion. But it's a global setting in Windows and you need to reboot the computer so that I'm looking for a more friendly solution.

  • I've found a tool called CodePageConverter which do exactly what I need, but can't a do it as batch job.

Does anyone know another tool (a command line tool would be perfect) to convert from a codepage to UTF-8?

Edit: As suggest by tkotitan seems iconv to be the solution I was looking for. There is a windows version of iconv. And now that I know the name of this tool, I was able to find over posts on stackoverflow dealing with analogous issues.

+6  A: 

In a unix world the utility is called iconv.

Not sure if there is a windows equivalent.

tkotitan
there's a port of iconv to work under cygwin; but i don't know if it's included by default
Javier
Thanks! And yes, there is a Windows version.
Name
+1  A: 

You can ask VS 2008 to open file with encoding (click Arrow near Open button in open dialog)

Or you can change regional settings to add russian region as default ;)

LicenseQ
Thanks. Why did Microsoft hide the function so much! I looked for it but I couldn't see it. Apparently this is only possible for single files and not for a whole project, but it's good to know that it is possible.
Name