Code::Blocks Forums

User forums => Help => Topic started by: alkisg on January 06, 2008, 02:54:43 pm

Title: No OEM charset support (a proposed solution)
Post by: alkisg on January 06, 2008, 02:54:43 pm
Hi,

There is a "Default encoding when opening files" combo box in options, with which a user can select custom file encodings. It's a great feature, especially useful for windows console programs.

Unfortunately, it lacks many charsets, such as OEM Greek (cp737), OEM Cyrillic (cp866) etc.

One way to support all OEM charsets on Windows (which is where OEM charsets are the problem) would be:

I haven't looked at the source code, but I think it'll be easy enough, codeblocks already has support for different charsets and when a file cannot be saved in the current encoding, it already warns the user and automatically uses utf8.

I can implement these functions for you if you like and post them here, just tell me if the prototypes are OK.
(btw I think wxScintilla uses utf8 internally, so maybe CP_ANSI should be replaced by CP_UTF8).

Finally, OEM charset should be automatically selected for console projects.

Thanks for your great IDE,
Alkis


P.S. existing workarounds for this problem that ... suck:
1) Call SetConsoleOutputCP() at program start:
=> is makes the code not portable
=> it requires users to change the console fonts to truetype
=> it doesn't work in real DOS or in full screen dos box.

2) Use gcc parameters -finput-charset and -fexec-charset:
=> they don't work with all compilers, not even with all gcc versions.

3) Use setlocale():
Same problems with (1).
Title: Re: No OEM charset support (a proposed solution)
Post by: JGM on January 06, 2008, 06:02:27 pm
If my mind is correct back in time, visual studio 6 have the same problem with console programs. it doesn't displayed correctly characters like "áéíóúñ". That would improve Code Blocks over other IDE's I think. I write spanish applications and I have to mess with the compiler options, that solution sounds really nice.
Title: Re: No OEM charset support (a proposed solution)
Post by: SuperSailorMoon on January 07, 2008, 01:53:44 pm
I support the suggestion of alkisg. Leed me to it!
Title: Re: No OEM charset support (a proposed solution)
Post by: alkisg on January 10, 2008, 07:21:15 am
If there is no interest in this from the developers, I guess we can also try to add the encoding we care about directly to wxWidgets:

How to add a new font encoding to wxWidgets:
http://fresh.t-systems-sfr.com/linux/misc/wxGTK-2.8.7.tar.gz:a/wxGTK-2.8.7/docs/tech/tn0018.txt