2012-08-31 24 views
9

Linux/x86_64のGCC 4.7には、Cソースファイルの文字列リテラルの内容を検証してデコードするデフォルトの文字エンコードがありますか?これは設定可能ですか?GCC 4.7ソース文字のエンコーディングと実行文字列リテラルのエンコーディング?

さらに、文字列リテラルの文字列データを出力のデータセクションにリンクすると、デフォルトの実行文字エンコードが行われますか?これは設定可能ですか?

どのような構成でも、実行文字エンコーディングとは異なるソース文字エンコーディングを使用できますか?

答えて

11

これらのオプションが実際に動作するかどうかわかりません(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. 
+0

のようなオプションを追加したsrcとexecのエンコーディングがデフォルトのUTF-8であるとき、それは実際にも文字列リテラルを検証した場合、私は疑問に思いますUTF-8を使用し、無効なバイトシーケンスが含まれている場合、または無効なバイトが通過するかどうかを判断します。 –

関連する問題