【发布时间】:2019-07-11 11:55:12
【问题描述】:
如何在 Windows 路径中加载非 ASCII 字符的 hunspell 字典?
Hunspell manual 建议:
在WIN32中 环境,使用以长路径前缀\?\开头的UTF-8编码路径来处理 独立于系统的字符编码和非常长的路径名。
所以我有代码来执行以下操作:
QString spell_aff = QStringLiteral(R"(\\?\%1%2.aff)").arg(path, newDict);
QString spell_dic = QStringLiteral(R"(\\?\%1%2.dic)").arg(path, newDict);
// while normally not a an issue, you can't mix forward and back slashes with the prefix
spell_dic = spell_aff.replace(QChar('/'), QStringLiteral("\\"));
spell_dic = spell_dic.replace(QChar('/'), QStringLiteral("\\"));
qDebug() << "right before Hunspell_create";
mpHunspell_system = Hunspell_create(spell_aff.toUtf8().constData(), spell_dic.toUtf8().constData());
qDebug() << "right after Hunspell_create";
这会将\\?\ 作为路径的前缀,使用microsoft documentation 中的注释所记录的一致目录分隔符,并将其转换为带有.toUtf8() 的UTF-8 编码。
但在 Windows 10 Pro 上运行代码失败:
如何解决?
使用 Qt5,MinGW 7.3.0。
我也做了适当的研究,据我所知,LibreOffice 做了同样的事情,而且似乎对他们有用:sspellimp.cxx、lingutil.hxx 和 lingutil.cxx。
【问题讨论】:
-
评论不用于扩展讨论;此对话是moved to chat。
标签: winapi non-ascii-characters hunspell