简体   繁体   English

GCC 4.7字符串文字的源字符编码和执行字符编码?

[英]GCC 4.7 Source Character Encoding and Execution Character Encoding For String Literals?

Does GCC 4.7 on Linux/x86_64 have a default character encoding by which it validates and decodes the contents of string literals in C source files? Linux / x86_64上的GCC 4.7是否具有默认字符编码,通过它可以验证和解码C源文件中字符串文字的内容? Is this configurable? 这是可配置的吗?

Further, when linking the string data from string literals into the data section of the output does it have a default execution character encoding? 此外,将字符串文字从字符串文字链接到输出的数据部分时,它是否具有默认的执行字符编码? Is this configurable? 这是可配置的吗?

In any configuration is it possible to have a source character encoding that differs from the execution character encoding? 在任何配置中,源字符编码都可能与执行字符编码不同吗? (That is will gcc ever transcode between character encodings?) (那gcc会在字符编码之间进行代码转换吗?)

I don't know how well these options actually work (not using them atm; I still prefer treating string literals as 'ASCII only', since localized strings come from external files anyway so it's mostly things like format strings or filenames), but they have added options like 我不知道这些选项的实际效果如何(不使用atm;我仍然更喜欢将字符串文字视为“仅ASCII”,因为本地化的字符串无论如何都来自外部文件,因此大多是格式字符串或文件名之类的东西),但是它们添加了诸如

-fexec-charset=charset
Set the execution character set, used for string and character constants. The default
is UTF-8. charset can be any encoding supported by the system's iconv library routine. 

-fwide-exec-charset=charset
Set the wide execution character set, used for wide string and character constants.
The default is UTF-32 or UTF-16, whichever corresponds to the width of wchar_t. As
with -fexec-charset, charset can be any encoding supported by the system's iconv
library routine; however, you will have problems with encodings that do not fit
exactly in wchar_t.

-finput-charset=charset
Set the input character set, used for translation from the character set of the
input file to the source character set used by GCC. If the locale does not specify,
or GCC cannot get this information from the locale, the default is UTF-8. This can
be overridden by either the locale or this command line option. Currently the command
line option takes precedence if there's a conflict. charset can be any encoding
supported by the system's iconv library routine. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM