简体   繁体   English

非 ASCII 文件路径 Windows

[英]non-ASCII file paths Windows

I work on Windows and have file paths with non-ASCII symbols.我在 Windows 上工作,并且文件路径带有非 ASCII 符号。 For non-ASCII symbols windows using wstring.对于非 ASCII 符号 windows 使用 wstring。 I am doing the conversion and pass them to luaL_dofile but it fails with can not find a file.我正在进行转换并将它们传递给 luaL_dofile 但它因找不到文件而失败。

Here is my example of code:这是我的代码示例:

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());

I know nothing about luaL_dofile , but it's rather unlikely it uses UTF-8.我对luaL_dofile ,但它不太可能使用 UTF-8。 Windows file API for Unicode unaware programs uses the ANSI codepage (which corresponds to the system default locale). Windows 文件 API 用于 Unicode 未知程序使用 ANSI 代码页(对应于系统默认区域设置)。 The ANSI codepage on English/US systems is 1252, but other system default locales have different codepages.英语/美国系统上的 ANSI 代码页是 1252,但其他系统默认语言环境具有不同的代码页。 Central European is 1250, Cyrillic is 1251, etc.中欧是 1250,西里尔文是 1251,等等。

Also, you could try generating the short name for the file (see the GetShortPathName API) and feed that.此外,您可以尝试为文件生成短名称(请参阅GetShortPathName API)并提供它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM