CMM: 1. remove /lib/encoding.h and use iconv library instead, as a result next point
2. better encoding in WebBrowser 3. fix error_init() in lib/dll.h git-svn-id: svn://kolibrios.org@5690 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
644e406bf8
commit
1ef1a0a3a0
@ -113,9 +113,9 @@ void BufEncode(int set_new_encoding)
|
||||
{
|
||||
strcpy(bufpointer, o_bufpointer);
|
||||
}
|
||||
if (set_new_encoding==_WIN) wintodos(bufpointer);
|
||||
if (set_new_encoding==_UTF) utf8rutodos(bufpointer);
|
||||
if (set_new_encoding==_KOI) koitodos(bufpointer);
|
||||
if (set_new_encoding==_WIN) bufpointer = ChangeCharset("CP1251", "CP866", bufpointer);
|
||||
if (set_new_encoding==_UTF) bufpointer = ChangeCharset("UTF-8", "CP866", bufpointer);
|
||||
if (set_new_encoding==_KOI) bufpointer = ChangeCharset("KOI8-RU", "CP866", bufpointer);
|
||||
}
|
||||
|
||||
void TWebBrowser::Prepare(dword bufpos, in_filesize){
|
||||
@ -653,3 +653,19 @@ int isTag(dword text)
|
||||
}
|
||||
|
||||
|
||||
:dword Hex2Symb(char* htmlcolor)
|
||||
{
|
||||
dword j=0, symbol=0;
|
||||
char ch=0x00;
|
||||
for (;j<2;j++)
|
||||
{
|
||||
ch=ESBYTE[htmlcolor+j];
|
||||
if (ch==0x0d) || (ch=='\9') RETURN 0;
|
||||
if ((ch>='0') && (ch<='9')) ch -= '0';
|
||||
if ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
||||
if ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
||||
symbol = symbol*0x10 + ch;
|
||||
}
|
||||
AL=symbol;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#define MEMSIZE 0x100000
|
||||
#include "..\lib\strings.h"
|
||||
#include "..\lib\gui.h"
|
||||
#include "..\lib\encoding.h"
|
||||
#include "..\lib\file_system.h"
|
||||
#include "..\lib\mem.h"
|
||||
#include "..\lib\draw_buf.h"
|
||||
@ -23,6 +22,7 @@
|
||||
#include "..\lib\obj\libio_lib.h"
|
||||
#include "..\lib\obj\libimg_lib.h"
|
||||
#include "..\lib\obj\http.h"
|
||||
#include "..\lib\obj\iconv.h"
|
||||
|
||||
//useful patterns
|
||||
#include "..\lib\patterns\libimg_load_skin.h"
|
||||
@ -30,14 +30,14 @@
|
||||
char homepage[] = FROM "html\\homepage.htm";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.15";
|
||||
char version[]=" ’¥ªáâ®¢ë© ¡à 㧥à 1.16";
|
||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||
char page_not_found[] = FROM "html\page_not_found_ru.htm";
|
||||
char accept_language[]= "Accept-Language: ru\n";
|
||||
#else
|
||||
char version[]=" Text-based Browser 1.15";
|
||||
char version[]=" Text-based Browser 1.16";
|
||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||
?define T_LAST_SLIDE "This slide is the last"
|
||||
char loading[] = "Loading...<br>";
|
||||
@ -128,6 +128,7 @@ void main()
|
||||
load_dll(libio, #libio_init,1);
|
||||
load_dll(libimg, #libimg_init,1);
|
||||
load_dll(libHTTP, #http_lib_init,1);
|
||||
load_dll(iconv_lib, #iconv_open,0);
|
||||
Libimg_LoadImage(#skin, abspath("wv_skin.png"));
|
||||
SetSkinColors();
|
||||
|
||||
@ -332,7 +333,7 @@ void Draw_Window()
|
||||
}
|
||||
|
||||
|
||||
void ChangeCharset(byte new_charset)
|
||||
void ChangeCharset1(byte new_charset)
|
||||
{
|
||||
BufEncode(new_charset);
|
||||
WB1.Parse();
|
||||
@ -349,19 +350,19 @@ void Scan(int id)
|
||||
switch (id)
|
||||
{
|
||||
case 011: //Ctrk+K
|
||||
ChangeCharset(_KOI);
|
||||
ChangeCharset1(_KOI);
|
||||
return;
|
||||
|
||||
case 021: //Ctrl+U
|
||||
ChangeCharset(_UTF);
|
||||
ChangeCharset1(_UTF);
|
||||
return;
|
||||
|
||||
case 004: //Ctrl+D
|
||||
ChangeCharset(_DOS);
|
||||
ChangeCharset1(_DOS);
|
||||
return;
|
||||
|
||||
case 005: //Win encoding
|
||||
ChangeCharset(_WIN);
|
||||
ChangeCharset1(_WIN);
|
||||
return;
|
||||
|
||||
case 009: //free img cache
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "..\lib\kolibri.h"
|
||||
#include "..\lib\strings.h"
|
||||
#include "..\lib\gui.h"
|
||||
#include "..\lib\encoding.h"
|
||||
#include "..\lib\draw_buf.h"
|
||||
#include "..\lib\file_system.h"
|
||||
#include "..\lib\mem.h"
|
||||
|
@ -19,7 +19,7 @@ char a_libdir[43] = "/sys/lib/\0";
|
||||
:inline void error_init(dword text)
|
||||
{
|
||||
dword TEXT_ERROR = malloc(1024);
|
||||
sprintf("%s `%s`' -E",_TEXT_ERROR_ADD,text);
|
||||
sprintf(TEXT_ERROR, "%s `%s`' -E",_TEXT_ERROR_ADD,text);
|
||||
notify(TEXT_ERROR);
|
||||
free(TEXT_ERROR);
|
||||
}
|
||||
|
@ -1,175 +0,0 @@
|
||||
#ifndef INCLUDE_ENCODING_H
|
||||
#define INCLUDE_ENCODING_H
|
||||
#print "[include <encoding.h>]\n"
|
||||
|
||||
#ifndef INCLUDE_KOLIBRI_H
|
||||
#include "../lib/kolibri.h"
|
||||
#endif
|
||||
|
||||
inline fastcall void wintodos( ESI)
|
||||
{
|
||||
while (BL=ESBYTE[ESI])
|
||||
{
|
||||
if (BL>=192)
|
||||
{
|
||||
if (BL>=240) ESBYTE[ESI] = BL - 16;
|
||||
else ESBYTE[ESI] = BL - 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BL==178) ESBYTE[ESI] = 73; //I
|
||||
if (BL==179) ESBYTE[ESI] = 105; //i
|
||||
if (BL==175) ESBYTE[ESI] = 244; //J
|
||||
if (BL==191) ESBYTE[ESI] = 245; //j
|
||||
if (BL==170) ESBYTE[ESI] = 242; //E
|
||||
if (BL==186) ESBYTE[ESI] = 243; //e
|
||||
if (BL==168) ESBYTE[ESI] = 240; //ð
|
||||
if (BL==184) ESBYTE[ESI] = 'e'; //e
|
||||
if (BL==180) ESBYTE[ESI] = 254; //ã
|
||||
if ((BL==147) || (BL==148) || (BL==171) || (BL==187)) ESBYTE[ESI] = 34;
|
||||
if ((BL==150) || (BL==151)) ESBYTE[ESI] = 45;
|
||||
}
|
||||
ESI++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
byte mas[66] = "î ¡æ¤¥ä£å¨©ª«¬®¯ïàáâ㦢ìë§èíéçꞀ<EFBFBD>–„…”ƒ•ˆ‰Š‹Œ<EFBFBD>Ž<EFBFBD>Ÿ<EFBFBD>‘’“†‚œ›‡˜<EFBFBD>™—š";
|
||||
inline fastcall void koitodos( EDI)
|
||||
{
|
||||
while (BL=ESBYTE[EDI])
|
||||
{
|
||||
if (BL >= 0xC0)
|
||||
{
|
||||
BL -= 0xC0;
|
||||
ESBYTE[EDI] = mas[BL];
|
||||
}
|
||||
//if (ESBYTE[EDI]=='\244') ESBYTE[EDI]='i';
|
||||
EDI++;
|
||||
}
|
||||
}
|
||||
|
||||
//Asper, lev
|
||||
//uncomplete
|
||||
inline fastcall void utf8rutodos( ESI)
|
||||
{
|
||||
EDI=ESI;
|
||||
while (BL=ESBYTE[ESI])
|
||||
{
|
||||
if (BL == 0xD0) || (BL == 0xD1) EDI--;
|
||||
else if (BL == 0x81) && (ESBYTE[ESI-1]==0xD0) ESBYTE[EDI] = 0xF0; //ø
|
||||
else if (BL == 0x91) && (ESBYTE[ESI-1]==0xD1) ESBYTE[EDI] = 0xF1; //ì
|
||||
//0xE2 0x80 - ñãðóïïèðîâàòü
|
||||
else if (BL == 0xE2) && (ESBYTE[ESI+1]==0x80)
|
||||
switch (ESBYTE[ESI+2])
|
||||
{
|
||||
case 0x93: //long defis
|
||||
case 0x94:
|
||||
{
|
||||
ESBYTE[EDI] = '-';
|
||||
ESI+=2;
|
||||
break;
|
||||
}
|
||||
case 0xA2: //central point
|
||||
{
|
||||
ESBYTE[EDI] = '*';
|
||||
ESI+=2;
|
||||
break;
|
||||
}
|
||||
case 0xA6: //ìíîãîòî÷èå
|
||||
{
|
||||
ESBYTE[EDI] = ESBYTE[EDI+1] = ESBYTE[EDI+2] = '.';
|
||||
EDI+=2;
|
||||
ESI+=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (BL == 0xC2) //òàáëèöó ïåðåêîäèðîâîê?
|
||||
switch(ESBYTE[ESI+1]) {
|
||||
case 0xAB: //"
|
||||
case 0xBB: //"
|
||||
{
|
||||
ESBYTE[EDI] = '\"';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
case 0xB7: // _
|
||||
{
|
||||
ESBYTE[EDI] = '_';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
case 0xA0: // Alt+160 - íåðàçáèâàþùèé ïðîáåë
|
||||
{
|
||||
ESBYTE[EDI] = ' ';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
case 0xB0: // ãðàäóñ
|
||||
{
|
||||
ESBYTE[EDI] = '\29';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
case 0xA9: // (c) --- âûëåò Î_î
|
||||
{
|
||||
ESBYTE[EDI] = 'c';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
case 0xAE: // (r)
|
||||
{
|
||||
ESBYTE[EDI] = 'r';
|
||||
ESI++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (BL >= 0x90) && (BL <= 0xAF)
|
||||
{
|
||||
BL -= 0x10;
|
||||
ESBYTE[EDI] = BL;
|
||||
}
|
||||
else if (BL >= 0x80) && (BL <= 0x8F)
|
||||
{
|
||||
BL += 0x60;
|
||||
ESBYTE[EDI] = BL;
|
||||
}
|
||||
else if (BL >= 0xB0) && (BL <= 0xBF)
|
||||
{
|
||||
BL -= 0x10;
|
||||
ESBYTE[EDI] = BL;
|
||||
}
|
||||
else ESBYTE[EDI] = BL;
|
||||
ESI++;
|
||||
EDI++;
|
||||
}
|
||||
while (EDI<ESI)
|
||||
{
|
||||
ESBYTE[EDI] = ' ';
|
||||
EDI++;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
:dword Hex2Symb(char* htmlcolor)
|
||||
{
|
||||
dword j=0, symbol=0;
|
||||
char ch=0x00;
|
||||
for (;j<2;j++)
|
||||
{
|
||||
ch=ESBYTE[htmlcolor+j];
|
||||
if (ch==0x0d) || (ch=='\9') RETURN 0;
|
||||
if ((ch>='0') && (ch<='9')) ch -= '0';
|
||||
if ((ch>='A') && (ch<='F')) ch -= 'A'-10;
|
||||
if ((ch>='a') && (ch<='f')) ch -= 'a'-10;
|
||||
symbol = symbol*0x10 + ch;
|
||||
}
|
||||
wintodos(#symbol);
|
||||
AL=symbol;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
@ -57,8 +57,8 @@ dword ChangeCharset(dword from_chs, to_chs, conv_buf)
|
||||
}
|
||||
|
||||
|
||||
char *charsets[] = { " ", "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866"};
|
||||
int cur_charset;
|
||||
:char *charsets[] = { " ", "UTF-8", "KOI8-RU", "CP1251", "CP1252", "ISO8859-5", "CP866"};
|
||||
:int cur_charset;
|
||||
enum {
|
||||
CH_NULL,
|
||||
CH_UTF8,
|
||||
|
@ -21,7 +21,7 @@
|
||||
// itoa(signed long number) --- convert the number as a string
|
||||
// atoi(dword text) --- convert a string as a number
|
||||
// strupr( ESI)
|
||||
// strlwr( ESI) --- kyrillic symbols may not work
|
||||
// strlwr( ESI) --- Cyrillic symbols may not work
|
||||
// strttl( EDX)
|
||||
// strtok( ESI)
|
||||
// strltrim(dword text) --- removes "blank" characters on the left (\r, \n and space)
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "../lib/strings.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "../lib/dll.h"
|
||||
#include "../lib/encoding.h"
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/file_system.h"
|
||||
#include "../lib/list_box.h"
|
||||
@ -106,7 +105,7 @@ void main() {
|
||||
load_dll(netcode_lib, #base64_encode,0);
|
||||
load_dll(libio, #libio_init,1);
|
||||
load_dll(libimg, #libimg_init,1);
|
||||
if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library - iconv.obj"); use_iconv=2; }
|
||||
load_dll(iconv_lib, #iconv_open,0);
|
||||
OpenMailDat();
|
||||
SetEventMask(0x27);
|
||||
LoginBoxLoop();
|
||||
|
@ -52,26 +52,17 @@ void ParseMail()
|
||||
void ConvertToDOS(dword inbuf, searchin)
|
||||
{
|
||||
dword dos_buf=0;
|
||||
if (use_iconv==1)
|
||||
{
|
||||
cur_charset = CH_CP866;
|
||||
if (strstri(searchin, "windows-1251")!=0) || (strstri(searchin, "windows1251")!=0)
|
||||
{ dos_buf = ChangeCharset("CP1251", "CP866", inbuf); cur_charset = CH_CP1251;}
|
||||
else if (strstri(searchin, "koi8-")!=0)
|
||||
{ dos_buf = ChangeCharset("KOI8-RU", "CP866", inbuf); cur_charset = CH_KOI8;}
|
||||
else if (strstri(searchin, "utf-8")!=0) || (strstri(searchin, "utf8")!=0)
|
||||
{ dos_buf = ChangeCharset("UTF-8", "CP866", inbuf); cur_charset = CH_UTF8;}
|
||||
else if (strstri(searchin, "iso8859-5")!=0) || (strstri(searchin, "iso-8859-5")!=0)
|
||||
{ dos_buf = ChangeCharset("ISO8859-5", "CP866", inbuf); cur_charset = CH_ISO8859_5;}
|
||||
else if (strstri(searchin, "windows-1252")!=0) || (strstri(searchin, "windows1252")!=0)
|
||||
{ dos_buf = ChangeCharset("CP1252", "CP866", inbuf); cur_charset = CH_CP1252;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strstri(searchin, "windows-1251")!=0) wintodos( inbuf); else
|
||||
if (strstri(searchin, "koi8-")!=0) koitodos( inbuf); else
|
||||
if (strstri(searchin, "utf-8")!=0) utf8rutodos( inbuf);
|
||||
}
|
||||
cur_charset = CH_CP866;
|
||||
if (strstri(searchin, "windows-1251")!=0) || (strstri(searchin, "windows1251")!=0)
|
||||
{ dos_buf = ChangeCharset("CP1251", "CP866", inbuf); cur_charset = CH_CP1251;}
|
||||
else if (strstri(searchin, "koi8-")!=0)
|
||||
{ dos_buf = ChangeCharset("KOI8-RU", "CP866", inbuf); cur_charset = CH_KOI8;}
|
||||
else if (strstri(searchin, "utf-8")!=0) || (strstri(searchin, "utf8")!=0)
|
||||
{ dos_buf = ChangeCharset("UTF-8", "CP866", inbuf); cur_charset = CH_UTF8;}
|
||||
else if (strstri(searchin, "iso8859-5")!=0) || (strstri(searchin, "iso-8859-5")!=0)
|
||||
{ dos_buf = ChangeCharset("ISO8859-5", "CP866", inbuf); cur_charset = CH_ISO8859_5;}
|
||||
else if (strstri(searchin, "windows-1252")!=0) || (strstri(searchin, "windows1252")!=0)
|
||||
{ dos_buf = ChangeCharset("CP1252", "CP866", inbuf); cur_charset = CH_CP1252;}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#define CUSTOM 0
|
||||
#define MANUAL 1
|
||||
char checked[3] = { 1, 0 };
|
||||
int use_iconv = 1;
|
||||
|
||||
char *text1[] = {"POP server adress:", "POP server port:", "SMTP server adress:", "SMTP server port:", '\0'};
|
||||
|
||||
@ -62,12 +61,6 @@ void SettingsDialog()
|
||||
}
|
||||
OptionsWindow();
|
||||
}
|
||||
if (id==20)
|
||||
{
|
||||
if (use_iconv==2) break;
|
||||
if (use_iconv==1) use_iconv=0; else use_iconv=1;
|
||||
OptionsWindow();
|
||||
}
|
||||
break;
|
||||
|
||||
case evKey:
|
||||
@ -120,7 +113,4 @@ void OptionsWindow()
|
||||
edit_box_draw stdcall(#POP_server_port_box);
|
||||
edit_box_draw stdcall(#SMTP_server_box);
|
||||
edit_box_draw stdcall(#SMTP_server_port_box);
|
||||
|
||||
WriteTextB(ELEM_X, 205, 0x90, system.color.work_text, "MailBox settings");
|
||||
CheckBox(ELEM_X, 230,12, 12, 20, "Use iconv library for converting text charsets", system.color.work_graph, system.color.work_text, use_iconv);
|
||||
}
|
@ -227,7 +227,7 @@ void DrawTmpDisks()
|
||||
for (i=0; i<disk_num; i++)
|
||||
{
|
||||
DefineButton(disk_pos_x[i], disk_pos_y[i], 65, 30, 20+i, 0xFFFfff);
|
||||
WriteText(disk_pos_x[i]+25,disk_pos_y[i]+6, 0x90, 0, #disk_list[i].Item);
|
||||
WriteText(disk_pos_x[i]+25,disk_pos_y[i]+2, 10110000b, 0, #disk_list[i].Item);
|
||||
real_id = disk_list[i].Item[3] - '0';
|
||||
WriteText(disk_pos_x[i]+25,disk_pos_y[i]+19, 0x80, 0x888888, ConvertSize(disk_sizes[real_id]));
|
||||
_PutImage(disk_pos_x[i]+5,disk_pos_y[i]+4, 14,14, 2*14*14*3+#icons);
|
||||
|
Loading…
Reference in New Issue
Block a user