Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: 00061205 on June 15, 2008, 04:59:25 PM

Title: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 00061205 on June 15, 2008, 04:59:25 PM
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.
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 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.
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 00061205 on June 15, 2008, 05:17:31 PM
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|
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: Biplab on June 15, 2008, 05:27:32 PM
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.
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: thomas on June 15, 2008, 06:33:30 PM
Rather, add no option, and don't use that byte order mark. UTF-8 is gcc's default encoding.
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 00061205 on June 16, 2008, 11:06:37 AM
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?
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 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"
Title: Re: Is there a method to save the source files in UTF-8 format in C::B?
Post by: 00061205 on June 16, 2008, 02:21:13 PM
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.