null character(s) ignored的解決方法
阿新 • • 發佈:2019-02-10
轉載:http://yleesun.blog.163.com/blog/static/294134022012793594255/
解決向Linux移植時程式碼中中文亂碼的方法 ( null character(s) ignored )
在向linux移植過程中,肯定會遇到已有程式碼中的中文在linux下顯示亂碼的問題。下面是一種解決方法:
1.在windows上把程式碼修改成unicode編碼。可以通過記事本開啟該檔案,再另存為unicode編碼。如果檔案比較多,可以藉助批量修改檔案編碼工具進行修改。網上有此類小工具。
2.在linux開啟修改編碼後的檔案,中文顯示正常,無亂碼。此時如果編譯的話,會出現以下警告和錯誤:
plugintemplate/libs/lib_profiling.h:221:81: error: null character(s) ignored
plugintemplate/libs/lib_profiling.h:221:83: error: null character(s) ignoredplugintemplate/libs/lib_profiling.h:221:85: error: null character(s) ignored
plugintemplate/libs/lib_profiling.h:221:87: error: null character(s) ignored
In file included from plugintemplate/includes/sufcommun.h:21,
from plugintemplate/includes/default.h:51, from serverplugin_main.cpp:10:
plugintemplate/libs/lib_profiling.h:149: error: expected unqualified-id before ‘/’ token
plugintemplate/libs/lib_profiling.h:221: error: ‘e’ does not name a type
導致此問題的原因並非程式碼錯誤。是修改檔案編碼導致。可以通過以下方法解決:
新建一個空文件,再開啟該檔案,把該檔案內容拷貝到新建的文件內。並命名該新建文件為該檔案。即用一個新建到文件替換掉該文件。