簡體   English   中英

非 ASCII 文件路徑 Windows

[英]non-ASCII file paths Windows

我在 Windows 上工作,並且文件路徑帶有非 ASCII 符號。 對於非 ASCII 符號 windows 使用 wstring。 我正在進行轉換並將它們傳遞給 luaL_dofile 但它因找不到文件而失敗。

這是我的代碼示例:

std::wstring wstr_path = "non-ASCII path"

using convert_type = std::codecvt_utf8_utf16<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
std::string str_path = converter.to_bytes(wstr_path);
luaL_dofile(mRoot, str_path.c_str());

我對luaL_dofile ,但它不太可能使用 UTF-8。 Windows 文件 API 用於 Unicode 未知程序使用 ANSI 代碼頁(對應於系統默認區域設置)。 英語/美國系統上的 ANSI 代碼頁是 1252,但其他系統默認語言環境具有不同的代碼頁。 中歐是 1250,西里爾文是 1251,等等。

此外,您可以嘗試為文件生成短名稱(請參閱GetShortPathName API)並提供它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM