If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
saifcoder
Experienced Solver
Posts: 80 Joined: Thu Nov 16, 2017 9:32 pm
Post
by saifcoder » Sun Dec 29, 2019 7:48 pm
Let's create sample WebView app.
Code: Select all
wxString MyText = wxT("<html><body>Hello</body></html>");
wxMemoryFSHandler::AddFile("MyFile.htm", MyText);
MyWebView->LoadURL("memory:MyFile.htm");
All work great, but when putting unicode text, the webview show blank white page!.
Code: Select all
wxString MyText = wxT("<html><body>أهلا</body></html>");
Debian 9 - GCC 6 - wxWidgets 3.x U
Win 10 - GCC 8 - wxWidgets 3.x U
Mac OS X 10.x - Clang - wxWidgets 3.x U
i am in love with WX. Yes.
saifcoder
Experienced Solver
Posts: 80 Joined: Thu Nov 16, 2017 9:32 pm
Post
by saifcoder » Sun Dec 29, 2019 7:55 pm
My build is Unicode, and i'm using unicode text in all widgets without any issue, except for webview.
Debian 9 - GCC 6 - wxWidgets 3.x U
Win 10 - GCC 8 - wxWidgets 3.x U
Mac OS X 10.x - Clang - wxWidgets 3.x U
i am in love with WX. Yes.
saifcoder
Experienced Solver
Posts: 80 Joined: Thu Nov 16, 2017 9:32 pm
Post
by saifcoder » Sun Dec 29, 2019 8:36 pm
In the official webview example it's show error.
Code: Select all
wxMemoryFSHandler::AddFile("page1.htm", wxT("<html><body>أهلا</body></html>"));
Attachments
webview_unicode.png (54.71 KiB) Viewed 772 times
Debian 9 - GCC 6 - wxWidgets 3.x U
Win 10 - GCC 8 - wxWidgets 3.x U
Mac OS X 10.x - Clang - wxWidgets 3.x U
i am in love with WX. Yes.
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Sun Dec 29, 2019 9:08 pm
Code: Select all
wxString s( wxT("<html><meta charset=\"UTF-8\"><body>hey hey: أهلا</body></html>") );
wxCharBuffer cb = s.ToUTF8();
wxMemoryFSHandler::AddFile("page1.htm", cb, strlen(cb) );
Use the source, Luke!
saifcoder
Experienced Solver
Posts: 80 Joined: Thu Nov 16, 2017 9:32 pm
Post
by saifcoder » Sun Dec 29, 2019 9:29 pm
Thank you so much doublemax for your help, so the default encoding it's not UTF-8! now I got it.
Ref:
https://docs.wxwidgets.org/trunk/overview_string.html
Debian 9 - GCC 6 - wxWidgets 3.x U
Win 10 - GCC 8 - wxWidgets 3.x U
Mac OS X 10.x - Clang - wxWidgets 3.x U
i am in love with WX. Yes.