GCC 4.7 字符串文字的源字符编码和执行字符编码? [英] GCC 4.7 Source Character Encoding and Execution Character Encoding For String Literals?

查看:34
本文介绍了GCC 4.7 字符串文字的源字符编码和执行字符编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux/x86_64 上的 GCC 4.7 是否具有默认字符编码,通过该编码验证和解码 C 源文件中字符串文字的内容?这个可以配置吗?

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? 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?

在任何配置中是否有可能有一个与执行字符编码不同的源字符编码?(也就是说 gcc 会在字符编码之间转码吗?)

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?)

推荐答案

我不知道这些选项实际上如何工作(不使用它们 atm;我仍然更喜欢将字符串文字视为仅 ASCII",因为本地化的字符串来无论如何都来自外部文件,所以它主要是格式字符串或文件名之类的东西),但他们添加了诸如

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

-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. 

这篇关于GCC 4.7 字符串文字的源字符编码和执行字符编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆