From f8fdd821fdb0f7992722d735bd5f379d65534753 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 28 Sep 2017 18:59:04 +0000 Subject: [PATCH] WebView: fix two issues with encoding git-svn-id: svn://kolibrios.org@7032 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 24 +++++++++++++++--------- programs/cmm/TWB/unicode_tags.h | 1 + programs/cmm/browser/WebView.c | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index f81e148e1a..0f668650a7 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -79,8 +79,7 @@ void TWebBrowser::DrawStyle() if (!header) { - ChangeCharset("UTF-8", "CP866", #line); - sprintf(#header, "%s - %s", #line, #version); + strcpy(#header, #line); line = 0; return; } @@ -266,7 +265,6 @@ void TWebBrowser::SetStyle() { if (istag("form")) if (!opened) ignor_text = false; if(istag("title")) { if (opened) header=NULL; - else DrawTitle(#header); return; } if (ignor_text) return; @@ -292,7 +290,15 @@ void TWebBrowser::SetStyle() { DrawBuf.Fill(bg_color); } } 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; } if (istag("a")) { @@ -423,6 +429,7 @@ void TWebBrowser::SetStyle() { void TWebBrowser::BufEncode(dword set_new_encoding) { + if (cur_encoding == set_new_encoding) return; if (o_bufpointer==0) { o_bufpointer = malloc(bufsize); @@ -432,11 +439,10 @@ void TWebBrowser::BufEncode(dword set_new_encoding) { strcpy(bufpointer, o_bufpointer); } - if (cur_encoding!=set_new_encoding) { - cur_encoding = set_new_encoding; - debugln(charsets[cur_encoding]); - bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); - } + debugval("cur_encoding ", cur_encoding); + debugval("set_new_encoding", set_new_encoding); + cur_encoding = set_new_encoding; + bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); } //============================================================================================ void TWebBrowser::DrawScroller() diff --git a/programs/cmm/TWB/unicode_tags.h b/programs/cmm/TWB/unicode_tags.h index 73b8723cd1..36363484db 100644 --- a/programs/cmm/TWB/unicode_tags.h +++ b/programs/cmm/TWB/unicode_tags.h @@ -29,6 +29,7 @@ char *unicode_tags[]={ "#8211", "-", "#151", "-", "#149", "-", +"#9642", "-", //square in the middle of the line "rsquo", "'", "#39", "'", diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 987ed2e25c..6452936b87 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -30,7 +30,7 @@ char homepage[] = FROM "html\\homepage.htm""\0"; #ifdef LANG_RUS -char version[]="Текстовый браузер 1.7"; +char version[]="Текстовый браузер 1.71"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" char loading[] = "Загрузка страницы...
"; @@ -43,7 +43,7 @@ char rmb_menu[] = Очистить кэш картинок Менеджер загрузок"; #else -char version[]="Text-based Browser 1.7"; +char version[]="Text-based Browser 1.71"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" char loading[] = "Loading...
";