Skip to content

Commit fbdc0b5

Browse files
committed
qt/windows: fix utf8 encoding of notes etc.
When entering chars like 'ü' as a tx note on Windows, the char was encoded as "\xef\xbf\xbd", which is displayed as '�'. The frontend handled it properly, but when sending the `QString` to Go, the conversion used this function: https://doc.qt.io/qt-5/qstring.html#toLocal8Bit in ``` backendCall(queryID, query.toLocal8Bit().constData()); ``` which uses whatever local codec is defined. In Go strings are UTF-8, so using `toUtf8()` instead is appropriate and fixes the issue. We change all instances of toLocal8bit to toUtf8 for the same reason, fixing possibly other existing bugs on Windows.
1 parent 0e45021 commit fbdc0b5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Fix Wallet Connect issue with required/optionalNamespace and handling all possible namespace definitions
1414
- Add Satoshi as an option in active currencies
1515
- Show address re-use warning and group UTXOs with the same address together in coin control.
16+
- Fix encoding of transaction notes on Windows
1617

1718
## 4.42.0
1819
- Preselect backup when there's only one backup available

frontends/qt/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class BitBoxApp : public SingleApplication
8282
// if the BitBoxApp is launched and also when it is already running, in which case
8383
// it is brought to the foreground automatically.
8484

85-
handleURI(openEvent->url().toString().toLocal8Bit().constData());
85+
handleURI(openEvent->url().toString().toUtf8().constData());
8686
}
8787
}
8888

@@ -103,7 +103,7 @@ class WebEnginePage : public QWebEnginePage {
103103
{
104104
// Log frontend console messages to the Go log.txt.
105105
QString formattedMsg = QString("msg: %1; line %2; source: %3").arg(message).arg(lineNumber).arg(sourceID);
106-
goLog(formattedMsg.toLocal8Bit().constData());
106+
goLog(formattedMsg.toUtf8().constData());
107107
}
108108
};
109109

@@ -127,7 +127,7 @@ class RequestInterceptor : public QWebEngineUrlRequestInterceptor {
127127
if (onBuyPage || onBitsurancePage) {
128128
if (info.firstPartyUrl().toString() == info.requestUrl().toString()) {
129129
// A link with target=_blank was clicked.
130-
systemOpen(info.requestUrl().toString().toLocal8Bit().constData());
130+
systemOpen(info.requestUrl().toString().toUtf8().constData());
131131
// No need to also load it in our page.
132132
info.block(true);
133133
}
@@ -407,11 +407,11 @@ int main(int argc, char *argv[])
407407
[&](int instanceId, QByteArray message) {
408408
QString arg = QString::fromUtf8(message);
409409
qDebug() << "Received arg from secondary instance:" << arg;
410-
handleURI(arg.toLocal8Bit().constData());
410+
handleURI(arg.toUtf8().constData());
411411
});
412412
// Handle URI which the app was launched with in the primary instance.
413413
if (a.arguments().size() == 2) {
414-
handleURI(a.arguments()[1].toLocal8Bit().constData());
414+
handleURI(a.arguments()[1].toUtf8().constData());
415415
}
416416

417417
return a.exec();

frontends/qt/webclass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class WebClass : public QObject
2121
Q_OBJECT
2222
public slots:
2323
void call(int queryID, const QString& query) {
24-
backendCall(queryID, query.toLocal8Bit().constData());
24+
backendCall(queryID, query.toUtf8().constData());
2525
}
2626
signals:
2727
void gotResponse(int queryID, QString response);

0 commit comments

Comments
 (0)