c++ - WideCharToMultiByte 不在英语操作系统上转换日语
问题描述
我需要将文件名System.String
从std::string
. 我同时使用日文和英文文件名。
对于英文文件名,没有问题。
只有日文文件名不会转换为std::string
英文 Windows 10。
我使用WideCharToMultiByte()
和代码页 932。
std::string marshal_as(System::String^ str)
{
std::string convertedstring;
size_t _size = 0;
cli::pin_ptr<const wchar_t> _pinned_ptr = PtrToStringChars(str);
_size = WideCharToMultiByte(932, 0, _pinned_ptr, str->Length, 0, 0, 0, 0);
if (_size > 0)
{
convertedstring.resize(_size);
char* buffer = &convertedstring[0];
WideCharToMultiByte(932, 0, _pinned_ptr, -1, &buffer[0], _size, 0, 0);
}
return convertedstring;
}
这里str
是"C:\\files\\ブ種別.pdf"
convertedstring
是"C:\\files\\ƒuŽí•Ê.pdf"
谁能帮我解决这个问题?
解决方案
我的问题已解决。我在控制面板的区域设置中启用了 Beta: Use Unicode UTF-8 for global language support 选项。
推荐阅读
- java - @Select 在没有参数而不是选择所有实体时引发错误(Datastax Java Driver Mapper)
- sql-server - 在 SSIS 中使用动态变量连接到 SQL Server
- c++ - 如何将独立的 c 应用程序组合成 c++ 应用程序?
- python - Pyrhon KeyError:101 当我尝试计算时间序列的多个预测时
- aem - 可编辑模板可以在旧原型(即 AEM 6.1)上工作吗?
- git - 将未推送的本地提交迁移到新存储库
- excel - 更快地从工作表中删除行
- node.js - 使用 React 显示标记列表
- reactjs - sh:反应脚本:找不到命令
- database - 我可以根据计算或其他字段修复 Access 数据库中的查找字段吗?