WebView: fix two issues with encoding

git-svn-id: svn://kolibrios.org@7032 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2017-09-28 18:59:04 +00:00
parent 29387f168a
commit f8fdd821fd
3 changed files with 18 additions and 11 deletions

View File

@ -79,8 +79,7 @@ void TWebBrowser::DrawStyle()
if (!header) if (!header)
{ {
ChangeCharset("UTF-8", "CP866", #line); strcpy(#header, #line);
sprintf(#header, "%s - %s", #line, #version);
line = 0; line = 0;
return; return;
} }
@ -266,7 +265,6 @@ void TWebBrowser::SetStyle() {
if (istag("form")) if (!opened) ignor_text = false; if (istag("form")) if (!opened) ignor_text = false;
if(istag("title")) { if(istag("title")) {
if (opened) header=NULL; if (opened) header=NULL;
else DrawTitle(#header);
return; return;
} }
if (ignor_text) return; if (ignor_text) return;
@ -292,7 +290,15 @@ void TWebBrowser::SetStyle() {
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
} }
} while(GetNextParam()); } while(GetNextParam());
if (opened) && (cur_encoding==CH_NULL) debugln("Document has no information about encoding, UTF will be used"); if (opened) && (cur_encoding==CH_NULL) {
cur_encoding = CH_UTF8;
debugln("Document has no information about encoding, UTF will be used");
}
if (opened) {
ChangeCharset(charsets[cur_encoding], "CP866", #header);
sprintf(#header, "%s - %s", #header, #version);
DrawTitle(#header);
}
return; return;
} }
if (istag("a")) { if (istag("a")) {
@ -423,6 +429,7 @@ void TWebBrowser::SetStyle() {
void TWebBrowser::BufEncode(dword set_new_encoding) void TWebBrowser::BufEncode(dword set_new_encoding)
{ {
if (cur_encoding == set_new_encoding) return;
if (o_bufpointer==0) if (o_bufpointer==0)
{ {
o_bufpointer = malloc(bufsize); o_bufpointer = malloc(bufsize);
@ -432,11 +439,10 @@ void TWebBrowser::BufEncode(dword set_new_encoding)
{ {
strcpy(bufpointer, o_bufpointer); strcpy(bufpointer, o_bufpointer);
} }
if (cur_encoding!=set_new_encoding) { debugval("cur_encoding ", cur_encoding);
cur_encoding = set_new_encoding; debugval("set_new_encoding", set_new_encoding);
debugln(charsets[cur_encoding]); cur_encoding = set_new_encoding;
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
}
} }
//============================================================================================ //============================================================================================
void TWebBrowser::DrawScroller() void TWebBrowser::DrawScroller()

View File

@ -29,6 +29,7 @@ char *unicode_tags[]={
"#8211", "-", "#8211", "-",
"#151", "-", "#151", "-",
"#149", "-", "#149", "-",
"#9642", "-", //square in the middle of the line
"rsquo", "'", "rsquo", "'",
"#39", "'", "#39", "'",

View File

@ -30,7 +30,7 @@
char homepage[] = FROM "html\\homepage.htm""\0"; char homepage[] = FROM "html\\homepage.htm""\0";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.7"; char version[]="’¥ªáâ®¢ë© ¡à ã§¥à 1.71";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤" ?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>"; char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
@ -43,7 +43,7 @@ char rmb_menu[] =
Žç¨áâ¨âì ªíè ª à⨭®ª Žç¨áâ¨âì ªíè ª à⨭®ª
Œ¥­¥¤¦¥à § £à㧮ª"; Œ¥­¥¤¦¥à § £à㧮ª";
#else #else
char version[]="Text-based Browser 1.7"; char version[]="Text-based Browser 1.71";
?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last" ?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>"; char loading[] = "Loading...<br>";