0

I am trying to read percentage encoded urls with umlauts, such as äüö,..., with Qt:

QString str = "Nu%CC%88rnberg"
qDebug() << QUrl::fromPercentEncoding(str.toUtf8());

But the output is Nu¨rnberg instead of Nürnberg. How can I correctly decode urls with umlauts in this form?

Regards,

Hyndrix
  • 4,282
  • 7
  • 41
  • 82
  • 2
    Your code looks correct. Where do you see the incorrect string? If you output it to a terminal window, it might be that it fails to show unicode characters. – vahancho Sep 10 '19 at 06:54
  • The output to the terminal window was the problem. – Hyndrix Sep 10 '19 at 13:12

1 Answers1

1

I have done this issue but I am little confused with result. First if you want to use letter ü use %C3%BC not %CC%88 (according to https://www.w3schools.com/tags/ref_urlencode.asp). So you need

QString str = "N%C3%BCrnberg";
QString encoded = QUrl::fromPercentEncoding(str.toUtf8());

But if you output it in qDebug() stream you can get different symbol (I guess it is because your default system encoding). But if you output it in GUI element you will have your ü symbol

QMessageBox::information(this, "", encoded);

this means main window.

Serhiy Kulish
  • 1,057
  • 1
  • 6
  • 8