Charset problem?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Charset problem?

Postby Dimkas » Wed Feb 08, 2017 3:43 am

Hello

I want localize default error page in cefclient

I found code which represent HTML page and add "TEST TEXT Rückgängig" to string.

Code: Select all
// Load a data: URI containing the error message.
void LoadErrorPage(CefRefPtr<CefFrame> frame,
                   const std::string& failed_url,
                   cef_errorcode_t error_code,
                   const std::string& other_info) {
  std::stringstream ss;
  ss << "<html><head><title>Page failed to load</title></head>"
        "<body bgcolor=\"white\">"
        "<h3>Page failed to load. TEST TEXT Rückgängig</h3>"
        "URL: <a href=\"" << failed_url << "\">"<< failed_url << "</a>"
        "<br/>Error: " << test_runner::GetErrorString(error_code) <<
        " (" << error_code << ")";

  ss << "</body></html>";

  frame->LoadURL(test_runner::GetDataURI(ss.str(), "text/html"));
}


As result, I see test text not recognized by browser. Sample text attached.
test.png
test.png (5.61 KiB) Viewed 4156 times


How can I localize error page?
Dimkas
Newbie
 
Posts: 6
Joined: Fri Feb 03, 2017 6:45 am

Re: Charset problem?

Postby magreenblatt » Wed Feb 08, 2017 10:56 am

You need to tell the browser what encoding you're using in the string. For example, add a BOM to the beginning of the string: https://en.wikipedia.org/wiki/Byte_order_mark
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Charset problem?

Postby Dimkas » Thu Feb 09, 2017 3:10 am

Thank you, works well.
Dimkas
Newbie
 
Posts: 6
Joined: Fri Feb 03, 2017 6:45 am

Re: Charset problem?

Postby Satrajit » Wed Nov 27, 2019 3:35 am

Can someone post an example of how was it resolved.
I am facing similar issue with Chinese characters as well.
Satrajit
Mentor
 
Posts: 87
Joined: Wed Jan 09, 2019 6:11 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 115 guests