【问题标题】:Android Studio error: UTF-16 (LE) byte order mark detected, but encoding is not supportedAndroid Studio 错误:检测到 UTF-16 (LE) 字节顺序标记,但不支持编码
【发布时间】:2020-06-20 08:48:09
【问题描述】:

我是 Android 工作室的新手,我想制作一个使用我的 c++ 代码的应用程序。我使用 Cmake 导入 .cpp 文件,并在构建项目时出现以下错误:

Build command failed.
Error while executing process F:\Android with arguments {SKD_Components\cmake\3.10.2.4988404\bin\ninja.exe -C A:\...\app\.cxx\cmake\debug\armeabi-v7a native-lib}
ninja: Entering directory `A:\...\app\.cxx\cmake\debug\armeabi-v7a'
[1/2] Building CXX object CMakeFiles/native-lib.dir/A_/Visual_Studio_Projects/.../filename.cpp.o
FAILED: CMakeFiles/native-lib.dir/A_/Visual_Studio_Projects/.../filename.cpp.o 
"F:\Android SKD_Components\ndk\20.0.5594570\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe" --target=armv7-none-linux-androideabi21 --gcc-toolchain="F:/Android SKD_Components/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64" --sysroot="F:/Android SKD_Components/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/sysroot"  -Dnative_lib_EXPORTS -IA:/Visual_Studio_Projects/PasswordGenerator/PasswordGenerator -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -march=armv7-a -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -O0 -fno-limit-debug-info  -fPIC -MD -MT CMakeFiles/native-lib.dir/A_/Visual_Studio_Projects/.../filename.cpp.o -MF CMakeFiles\native-lib.dir\A_\Visual_Studio_Projects\...\filename.cpp.o.d -o CMakeFiles/native-lib.dir/A_/Visual_Studio_Projects/.../filename.cpp.o -c A:/Visual_Studio_Projects/PasswordGenerator/PasswordGenerator.cpp
fatal error: UTF-16 (LE) byte order mark detected in 'A:/Visual_Studio_Projects/.../filename.cpp', but encoding is not supported
1 error generated.
ninja: build stopped: subcommand failed.

与编码有关,但我真的不知道是什么。 谁有解决办法?

【问题讨论】:

    标签: android c++ encoding utf-16 build-error


    【解决方案1】:

    错误告诉您,您的 filename.cpp 源文件以UTF-16LE BOM(字节FF FE)开头,表示文件内容已以UTF-16 编码。您使用的编译器不支持编译该编码的源文件。您需要将 .cpp 文件的编码更改为另一种编码,最好是 7/8 位编码,例如 UTF-8 或更可能只是 ASCII。无论您使用哪个编辑器创建该文件,请检查它是否具有在保存文件时指定不同编码的选项。否则,您将不得不使用第 3 方工具重新编码现有文件,例如 iconv

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-16
      • 1970-01-01
      • 2015-04-24
      • 2013-06-23
      • 2014-12-24
      • 2011-07-13
      • 2018-05-18
      相关资源
      最近更新 更多