簡體   English   中英

如何使用 utf-8 編碼在 Qt5 WebEngineView 中加載 HTML 頁面?

[英]How to load an HTML page in Qt5 WebEngineView using utf-8 encoding?

我有一個 html 頁面,我使用 QWebEngineView 將其加載到我的 Qt5 應用程序中,如下所示:

QWebEngineView* webEngineView = new QWebEngineView();
webEngineView->setUrl("index.html");

我在 html 文件中使用 UTF-8 字符,例如“...”(#x2026;在 html 中),顯示為“?” 在應用程序中。

html 文件包含<meta http-equiv="Content-Type" content="text/html; charset=utf-8"並且我嘗試使用webEngineView->settings()->setDefaultTextEncoding("utf-8"); 無濟於事。

誰能幫我顯示這些字符?

我發現問題不在於setUrl()方法,而在於我的 JS 文件中的本地化函數。 該函數明確地將編碼設置為 ASCII 而不是 UTF-8。

setUrl()方法似乎以正確的編碼加載 html 文件,而沒有在 C++ 代碼中明確指定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM