diff --git a/src/xmlpatterns/api/qcoloringmessagehandler.cpp b/src/xmlpatterns/api/qcoloringmessagehandler.cpp
index dc574e3a1b4c10e4dbc012dc309175deb956a6a9..b7d0d9f88138340a18f0e1cdf104305355f9cd19 100644
--- a/src/xmlpatterns/api/qcoloringmessagehandler.cpp
+++ b/src/xmlpatterns/api/qcoloringmessagehandler.cpp
@@ -84,14 +84,14 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
         {
             if(hasLine)
             {
-                writeUncolored(QXmlPatternistCLI::tr("Warning in %1, at line %2, column %3: %4").arg(QString::fromLatin1(sourceLocation.uri().toEncoded()),
+                writeUncolored(QXmlPatternistCLI::tr("Warning in %1, at line %2, column %3: %4").arg(sourceLocation.uri().toString(),
                                                                                                  QString::number(sourceLocation.line()),
                                                                                                  QString::number(sourceLocation.column()),
                                                                                                  colorifyDescription(description)));
             }
             else
             {
-                writeUncolored(QXmlPatternistCLI::tr("Warning in %1: %2").arg(QString::fromLatin1(sourceLocation.uri().toEncoded()),
+                writeUncolored(QXmlPatternistCLI::tr("Warning in %1: %2").arg(sourceLocation.uri().toString(),
                                                                           colorifyDescription(description)));
             }
 
@@ -109,7 +109,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
             if(sourceLocation.isNull())
                 location = QXmlPatternistCLI::tr("Unknown location");
             else
-                location = QString::fromLatin1(sourceLocation.uri().toEncoded());
+                location = sourceLocation.uri().toString();
 
             QString errorId;
             /* If it's a standard error code, we don't want to output the
@@ -117,7 +117,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type,
             if(uri.toString() == QLatin1String("http://www.w3.org/2005/xqt-errors"))
                 errorId = errorCode;
             else
-                errorId = QString::fromLatin1(identifier.toEncoded());
+                errorId = identifier.toString();
 
             if(hasLine)
             {
diff --git a/src/xmlpatterns/functions/qstringvaluefns.cpp b/src/xmlpatterns/functions/qstringvaluefns.cpp
index d3cb62f084f2ee8c9cfbef103bd51b08a2f0cf59..06567215f50e0071ca4178ae44b3f9b104ccfa5a 100644
--- a/src/xmlpatterns/functions/qstringvaluefns.cpp
+++ b/src/xmlpatterns/functions/qstringvaluefns.cpp
@@ -345,9 +345,8 @@ Item EncodeString::evaluateSingleton(const DynamicContext::Ptr &context) const
     if(!item)
         return CommonValues::EmptyString;
 
-    return AtomicString::fromValue(QString::fromAscii(QUrl::toPercentEncoding(item.stringValue(),
-                                                                        m_excludeChars,
-                                                                        m_includeChars).constData()));
+    return AtomicString::fromValue(item.stringValue().toUtf8().toPercentEncoding(m_excludeChars,
+                                                                        m_includeChars).constData());
 }
 
 const char *const EncodeForURIFN::include = "#!*'()";