1

If I put url http://www.äsdf.de/bla/bla into QUrl, how can I then restore url with original symbols?

It's ok that QUrl will fix some characters, but I'd like to display original äsdf in url instead of xn--sdf-pla.

I am aware about QString QUrl::fromAce(const QByteArray &domain), but it requires QByteArray instead of QUrl instance.

4

1 回答 1

2

You can use QUrl::toDisplayString with the default PrettyDecoded formatting option, or any other value among enum ComponentFormattingOption:

QUrl url{"http://www.äsdf.de/bla/bla"};

QString original_string =
    url.toDisplayString(); // default is QUrl::PrettyDecoded

QString original_string_with_encoded_spaces =
    url.toDisplayString(QUrl::EncodeSpaces);
于 2016-11-18T12:26:58.250 回答