Is it possible to get GCC to compile UTF-8 with BOM source files?

前端 未结 2 1604
滥情空心
滥情空心 2020-12-10 13:24

I develop C++ cross platform using Microsoft Visual Studio on Windows and GCC on uBuntu Linux.

In Visual Studio I can use unicode symbols like "π

2条回答
  •  孤城傲影
    2020-12-10 14:07

    According to the GCC Wiki, this isn't supported yet. You can use -fextended-identifiers and pre-process your code to convert the identifiers to UCN. From the linked page:

    perl -pe 'BEGIN { binmode STDIN, ":utf8"; } s/(.)/ord($1) < 128 ? $1 : sprintf("\\U%08x", ord($1))/ge;' 
    

    See also g++ unicode variable name and Unicode Identifiers and Source Code in C++11?

提交回复
热议问题