[英]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.