News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Need some help with source encodings

Started by Grygoriy, June 04, 2007, 09:53:29 PM

Previous topic - Next topic

Grygoriy


Hi

I'm using CB, and I need some help.
My source files' encoding is UTF-8.
CB is using UTF-8 without BOM, but VS 2005 supports UTF-8 with BOM only. So if I want to build my project under Windows using VS 2005, I got some trash symbols insted of russian ones. I think that VS uses BOM to differ UTF-8 source files' encoding from Ansi one. And when it begins compilation, it compiles files, assuming that encoding is ansi.. And i have some strange symbols as an output )
So can you suggest some elegant solution for this problem?

TDragon

Edit->File encoding->Save byte-order-mark (BOM)
:D
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Grygoriy

You see, I want to store sources in UTF-8 without BOM, so maybe some scripting will help me.. I will attempt to add BOM during compilation, and then to remove it back..
But it's a little bit ugly solution ))

TDragon

Quote from: Grygoriy on June 04, 2007, 10:07:54 PM
You see, I want to store sources in UTF-8 without BOM, ...
Dare I ask why? If MSVC seems to expect it, why not use it?
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Grygoriy

It seems to me that UTF-8 without BOM just more universal, and BOM is not supported by some editors.
Am I wrong?

TDragon

No, you're not wrong.

If you truly need for these source files to be compatible with editors that don't read and write a BOM, or compilers that can't cope, then the correct thing to do would be to avoid using non-standard characters in the source files, and use translation tools such as gettext to internationalize your program.

This is only really necessary for popular, internationalized projects which are designed to be portable between compilers, however, and I get the impression that yours is not. This is a good time to apply the YAGNI principle -- don't try to plan for every eventuality.

Cheers,
John E. / TDM
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)