本文介绍了如何在Windows路径中使用非ASCII字符加载hunspell词典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows路径中使用非ASCII字符加载hunspell词典?

How to load hunspell dictionary in Windows path with non-ASCII characters?

Hunspell手册建议:

所以我有执行以下操作的代码:

So I have code to do the following:

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文档,并使用.toUtf8().

This prefixes \\?\ to the path, uses a consistent directory separator as documented by the note in microsoft documentation, and converts it to UTF-8 encoding with .toUtf8().

但是在Windows 10 Pro上运行代码失败:

Yet running the code out on Windows 10 Pro fails:

如何解决?

使用Qt5,MinGW 7.3.0.

Using Qt5, MinGW 7.3.0.

我也进行了适当的研究,据我所知,LibreOffice可以做同样的事情,并且似乎可以为他们服务: sspellimp.cxx lingutil.hxx lingutil.cxx .

I've also done due research and as far as I can see, LibreOffice does the same thing and it seemingly works for them: sspellimp.cxx, lingutil.hxx, and lingutil.cxx.

推荐答案

您可以使用 GetShortPathNameW 以获得Hunspell将理解的纯ASCII路径.有关示例,请参见 QTIFW-175 .

You can use GetShortPathNameW to obtain a pure-ASCII path that Hunspell will understand. See QTIFW-175 for an example.

(感谢)

这篇关于如何在Windows路径中使用非ASCII字符加载hunspell词典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:34