Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: codecub on January 15, 2014, 08:55:05 pm

Title: How to make CB editor and Windows agree on a character set?
Post by: codecub on January 15, 2014, 08:55:05 pm
Hi,

how can I tell CB's editor "make my C console program to conform to Windows' console codepage 850"?

I do not see any possibility in Settings > Editor > Other Settings

Thank you,

codecub

P.S. I use CB 13.12 on Windows 8 (Release 13.12 rev 9501 (2013/12/25 19:25:45) gcc 4.7.1 Windows/unicode - 32 bit)
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: BlueHazzard on January 15, 2014, 09:32:37 pm
As far as i know this can't be done at compile time, so it is not a c::b related issue, and so this forum is the wrong place to ask...

anyway her is a hint to google for: system("chcp XXXX");

(and a personal recommendation: use utf8 in your c/c++ files and in your windows console)

greetings
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: codecub on January 15, 2014, 10:02:21 pm
@BlueHazzard:

Thanks, but I tried all that before, such as chcp 65001 and setting CB's editor to utf8, to no avail!
And I was posting to this forum because in
http://stackoverflow.com/questions/17808673/c-spanish-question-mark (http://stackoverflow.com/questions/17808673/c-spanish-question-mark)
they state
Quote
The fundamental problem is...that the console and your C++ text editor disagree on what that character is. The two are using different character codes for many characters beyond those needed for English.
Since changing Windows' console coding to 65001 (supposedly utf8) did not work, I thought naively CB's editor would be more flexible and I could get him to use codepage 850. So I turned to this forum, because I use the CB text editor.

So, bye-bye Windows  :(, and hello Linux for C-console programs  because CB and shell work very well together in Ubuntu
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: BlueHazzard on January 15, 2014, 10:46:09 pm
the steps i did to make unicode possible on windows (i use utf 8 so i can use the code on linux and windows easily)

1) On windows system("chcp 65001"); as first code line in main
2) you have to use printf on widows, cout doesn't work
3) Save all files as UTF-8 encoded:
    * Edit -> File Encoding -> untick System defaults
    * Edit -> File Encoding ->tick utf8
4) save file ( check if at the bottom  is written UTF-8)
5) Select an utf8 capable font in all cmd windows. (not the standard font) (eg. use Lucida Console)
6) compile and run

with this method you don't have to use the ugly L"" and wcout and wchar_t things...

i hope this works... I can't test it because i don't have a windows machine anymore...

greetings

___________________________________________________________-
http://www.utf8everywhere.org/
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: codecub on January 16, 2014, 07:21:06 am
Your steps work great with CB on Windows 8 64bit, thank you so much  :)
 
Thank you,

codecub
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: codecub on January 16, 2014, 12:22:05 pm
And your recipe works also with naked mingw and Notepad++ as editor. I'll go open the bubbly!
Title: Re: How to make CB editor and Windows agree on a character set?
Post by: Xavier65 on September 01, 2018, 05:21:27 pm
Good evening.  I tried everything describe in this topic and in the other topic: http://forums.codeblocks.org/index.php/topic,22168.msg150872.html#msg150872
Nothing seems to work, unless you want to put some addition to the code itself.  I was told that that the cons uses OEM 866 encoding, and that the same encoding has to be set in the CodeBlocks editor.  But the editor does not offer that encoding.
Please see my topic:
http://forums.codeblocks.org/index.php/topic,22799.msg154918.html#msg154918
Any suggestions?