2012-08-31 12 views
9

GCC 4.7 su Linux/x86_64 ha una codifica di caratteri predefinita con cui convalida e decodifica il contenuto di stringhe letterali nei file di origine C? È configurabile?GCC 4.7 Codifica dei caratteri di origine e codifica dei caratteri di esecuzione per i valori letterali stringa?

Inoltre, quando si collegano i dati di stringa da stringhe letterali alla sezione dati dell'output, ha una codifica di caratteri di esecuzione predefinita? È configurabile?

In qualsiasi configurazione è possibile avere una codifica dei caratteri di origine diversa dalla codifica dei caratteri di esecuzione? (Cioè gcc mai transcodificare tra codifiche di caratteri?)

risposta

11

Non so quanto bene funzionino queste opzioni (non li uso, ma preferisco trattare i valori letterali stringa come "ASCII only", poiché le stringhe localizzate provengono da file esterni comunque così è per lo più cose come stringhe di formato o nomi di file), ma hanno aggiunto le opzioni come

-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

Chissà se quando lo src e la codifica exec è l'impostazione predefinita UTF-8, in realtà convalida la stringa letterale come pure formato UTF-8 e genera un errore se contiene sequenze di byte non valide o se lascia passare solo i byte non validi. –

Problemi correlati