Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: zaazbb on December 18, 2011, 04:42:33 am

Title: none english code in codeblocks, became unreadable code??
Post by: zaazbb on December 18, 2011, 04:42:33 am
when my c++ code have chinese character, CodeBlock save file as UTF8 automatically,
 so my chinese character now is unreadable code. how to change it??

when i change file encode to window936, gcc compiler meet errors.??

How can i use none english code in codeblocks???
Title: Re: none english code in codeblocks, became unreadable code??
Post by: huzhongshan on December 18, 2011, 09:49:05 am
I use chinese as "string" , donot meet such things.
Title: Re: none english code in codeblocks, became unreadable code??
Post by: ollydbg on December 18, 2011, 10:00:30 am
so my chinese character now is unreadable code. how to change it??
Why?
You save your file in UTF8, and you should read/open it in UTF8.
Title: Re: none english code in codeblocks, became unreadable code??
Post by: playxiaobaicai on December 18, 2011, 10:19:57 am
I think you had better use English! After all, it's a English IDE.
Title: Re: none english code in codeblocks, became unreadable code??
Post by: Jenna on December 18, 2011, 10:46:55 am
when my c++ code have chinese character, CodeBlock save file as UTF8 automatically,
 so my chinese character now is unreadable code. how to change it??

when i change file encode to window936, gcc compiler meet errors.??

How can i use none english code in codeblocks???
Where is the code unreadable ?
Should be readable in C::B, if it is opened as utf-8.
Title: Re: none english code in codeblocks, became unreadable code??
Post by: zaazbb on December 19, 2011, 09:08:43 am
when i build my project, the CB show a message as "encode changed ..", and my file save as utf8 automatily.   now, build and run my gui, the control text are unreadable. 
Title: Re: none english code in codeblocks, became unreadable code??
Post by: thomas on December 19, 2011, 10:07:19 am
That is not surprising, you're using different code pages when editing/compiling and running the program, so your Chinese characters come out as rubbish.

If you insist on writing Chinese in a non-Unicode program (which is somewhat unwise), you need to tell the compiler that you want to do such a thing, the switch for that would be something like -finput-charset=window936 for gcc. If you don't tell the compiler anything, it assumes UTF-8 encoding.

Otherwise, leave everything as it is in Code::Blocks and write a proper Unicode program (including L"" strings and the correct #defines for your toolkit/os) and you will have no such problems.
Title: Re: none english code in codeblocks, became unreadable code??
Post by: zaazbb on December 21, 2011, 03:41:11 pm
That is not surprising, you're using different code pages when editing/compiling and running the program, so your Chinese characters come out as rubbish.

If you insist on writing Chinese in a non-Unicode program (which is somewhat unwise), you need to tell the compiler that you want to do such a thing, the switch for that would be something like -finput-charset=window936 for gcc. If you don't tell the compiler anything, it assumes UTF-8 encoding.

Otherwise, leave everything as it is in Code::Blocks and write a proper Unicode program (including L"" strings and the correct #defines for your toolkit/os) and you will have no such problems.

thank you very much!~~ ;D