News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Is there a method to save the source files in UTF-8 format in C::B?

Started by 00061205, June 15, 2008, 04:59:25 PM

Previous topic - Next topic

00061205

Is there a method to save the source files in UTF-8 format in C::B?
In windows version C:B,the source files will not save by UTF-8 format. Gcc will report error if there are some local characters (eg. á é í ó ú ñ Ñ É 中文) in the source files. If we convert the source files to UTF-8 format manually with other applications this problem will overcome.

Biplab

Yes there is. Click-

1) Edit > File encoding > UTF-8.
2) Edit > File encoding > Save byte-order-mark (BOM)

The second option is necessary if you want to force every source files to be detected as UTF-8.
Be a part of the solution, not a part of the problem.

00061205

Quote from: Biplab on June 15, 2008, 05:04:45 PM
Yes there is. Click-

1) Edit > File encoding > UTF-8.
2) Edit > File encoding > Save byte-order-mark (BOM)

The second option is necessary if you want to force every source files to be detected as UTF-8.
Thanks.
It works when just enable  Edit > File encoding > UTF-8. When I complie with both enabled I get this error message:E:\CodeBlocks\CBProjects\hword\hword.cpp|1|error: stray '\239' in program|

Biplab

Quote from: 00061205 on June 15, 2008, 05:17:31 PM
Thanks.
It works when just enable  Edit > File encoding > UTF-8. When I complie with both enabled I get this error message:E:\CodeBlocks\CBProjects\hword\hword.cpp|1|error: stray '\239' in program|

Try adding -finput-charset=utf-8 to compiler options.
Be a part of the solution, not a part of the problem.

thomas

Rather, add no option, and don't use that byte order mark. UTF-8 is gcc's default encoding.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

00061205

I must manually enable edit->file encoding->utf-8 before i compile a new file which contain unicode characters.
How to set C::B handle file in UTF-8 format defaultly?

MortenMacFly

Quote from: 00061205 on June 16, 2008, 11:06:37 AM
How to set C::B handle file in UTF-8 format defaultly?
Settings -> Editor -> General Settings -> (in the "font" part:) "Default encoding when opening files"
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

00061205

Quote from: MortenMacFly on June 16, 2008, 11:21:49 AM
Quote from: 00061205 on June 16, 2008, 11:06:37 AM
How to set C::B handle file in UTF-8 format defaultly?
Settings -> Editor -> General Settings -> (in the "font" part:) "Default encoding when opening files"

Thanks MortenMacFly.