Author Topic: Need some help with source encodings  (Read 3643 times)

Grygoriy

  • Guest
Need some help with source encodings
« on: June 04, 2007, 09:53:29 pm »

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?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Need some help with source encodings
« Reply #1 on: June 04, 2007, 09:57:36 pm »
Edit->File encoding->Save byte-order-mark (BOM)
:D
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Grygoriy

  • Guest
Re: Need some help with source encodings
« Reply #2 on: June 04, 2007, 10:07:54 pm »
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 ))

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Need some help with source encodings
« Reply #3 on: June 04, 2007, 10:55:52 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?
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Grygoriy

  • Guest
Re: Need some help with source encodings
« Reply #4 on: June 06, 2007, 10:13:26 am »
It seems to me that UTF-8 without BOM just more universal, and BOM is not supported by some editors.
Am I wrong?

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Need some help with source encodings
« Reply #5 on: June 06, 2007, 04:04:24 pm »
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
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Grygoriy

  • Guest
Re: Need some help with source encodings
« Reply #6 on: June 06, 2007, 09:55:08 pm »
Thanks )