Effect of -finput-charset in gcc and phases of translation

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jun 6 07:54:00 GMT 2019


On Thu, 6 Jun 2019 at 02:35, esoteric escape <manips88@gmail.com> wrote:
>
> Thanks! It was a little tricky to take in especially when code pages are involved.
>
> So,
>
> If -finput-charset and -fexec-charset are the same then no conversion is performed. That is clear.
> If -finput-charset and -fexec-charset are not set then no conversion is performed either. Because it appears, GCC cannot get system locale under Windows so -finput-charset is UTF-8 by default and so is -fexec-charset so again both are same.

Right.

> Only if only of these are specified, then a conversion is performed and -fexec-charset is always UTF-8.

-fexec-charset is UTF-8 by default, but you can change it.

> That means if I use Windows 1251 or a UTF-8 source file,

Using Windows 1251 or UTF-8 source files is irrelevant. GCC doesn't
know what you think the source file contains. All that matters is the
values of the options and any codeset specified by the locale.

> with none of these options specified, then only raw bytes will be read and no conversion will happen at all?

If you don't use -finput-charset or -fexec-charset (and you're on
Windows so there's no locale codeset) then the two charsets are the
same, so no conversion happens.



More information about the Gcc-help mailing list