mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-17 15:21:30 +02:00
polyseed: use Qt for Unicode normalization
Boost is unreliable for this purpose
This commit is contained in:
@@ -9,17 +9,18 @@
|
||||
#include <sodium/randombytes.h>
|
||||
#include <boost/locale.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace polyseed {
|
||||
|
||||
static std::locale locale;
|
||||
|
||||
static size_t utf8_nfc(const char* str, polyseed_str norm) {
|
||||
auto s = boost::locale::normalize(str, boost::locale::norm_type::norm_nfc, locale);
|
||||
auto Qstr = QString(str);
|
||||
auto Qs = Qstr.normalized(QString::NormalizationForm_C);
|
||||
auto s = Qs.toStdString();
|
||||
size_t size = std::min(s.size(), (size_t)POLYSEED_STR_SIZE - 1);
|
||||
s.copy(norm, size);
|
||||
norm[size] = '\0';
|
||||
@@ -28,7 +29,9 @@ namespace polyseed {
|
||||
}
|
||||
|
||||
static size_t utf8_nfkd(const char* str, polyseed_str norm) {
|
||||
auto s = boost::locale::normalize(str, boost::locale::norm_type::norm_nfkd, locale);
|
||||
auto Qstr = QString(str);
|
||||
auto Qs = Qstr.normalized(QString::NormalizationForm_KD);
|
||||
auto s = Qs.toStdString();
|
||||
size_t size = std::min(s.size(), (size_t)POLYSEED_STR_SIZE - 1);
|
||||
s.copy(norm, size);
|
||||
norm[size] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user