【问题标题】:Red hat EnterPrise Edition 4 GCC compiler support utf8 with BOMRed hat Enterprise Edition 4 GCC 编译器支持带有 BOM 的 utf8
【发布时间】:2013-03-21 10:05:16
【问题描述】:

Red Hat Enterprise Edition 4 gcc 编译器是否支持 UTF8 和 BOM 文件?

如果是,我需要哪个 gcc 编译器版本来编译带有 BOM 的 UTF8 编码的 C++ 文件?

我目前正在使用 gcc 3.4.6 版,它给了我以下错误:-

:1: error: stray '\239' in program
 1: error: stray '\187' in program
    error: stray '\191' in program

【问题讨论】:

    标签: c++ linux gcc


    【解决方案1】:

    似乎只有GCC versions 4.4 and above 支持带有BOM 的UTF-8。

    GCC 4.4 是在 RHEL 6 中引入的,它也可以作为单独的包在 RHEL 5 中使用,gcc44。我不知道是否有适用于 RHEL4 的 GCC 4.4 包。

    如果您必须使用 GCC 3.4.6,您可以尝试在构建系统中添加一个“预处理”步骤来删除 BOM。一个非常简单的例子(取自here)是:

    tail --bytes=+4 source.cpp > sourceWithoutBOM.cpp
    

    【讨论】:

      猜你喜欢
      • 2021-01-22
      • 2016-11-30
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      相关资源
      最近更新 更多