The OpenNET Project / Index page

[ новости/++ | форум | wiki | теги ]

Jabbe-client PSI и русские локали в Xorg (xorg codepage psi jabber patch cp866)


<< Предыдущая ИНДЕКС Исправить src / Печать Следующая >>
Ключевые слова: xorg, codepage, psi, jabber, patch, cp866,  (найти похожие документы)
From: WatchCat Date: Mon, 21 Dec 2008 17:02:14 +0000 (UTC) Subject: Jabbe-client PSI и русские локали в Xorg Оригинал: http://www.opennet.ru/openforum/vsluhforumID15/2365.html В связи с производственной необходимостью в прошлом году возился с русскими локалями в Xorg. В частности дописал в библиотеку libX11 поддержку локали CP866, адаптировав найденные в сети куски соответствующих патчей. Вот с этой локалью и поэкспериментировал - судя по выводу xev, русские буквы вводятся (Cyrillic_*), да и в большинстве используемых мной прогамм русский в 866 кодировке заработал. А вот Jabber-клиент PSI почему-то в этой локали работать не хочет. В 1251 - пожалуйста, а в 866 в поле ввода сообщения вводятся всякие странные символы. Так как PSI написан с использованием Qt, то я запустил qtconfig - в нем русские буквы ввести можно (там где "sample text"). Вот текст патча LibX11 для использования локали CP866. diff -Naur libx11-1.0.3.cp866/configure.ac libx11-1.0.3/configure.ac --- libx11-1.0.3.cp866/configure.ac 2005-11-10 00:19:12 +0300 +++ libx11-1.0.3/configure.ac 2005-12-03 21:16:10 +0300 @@ -349,6 +349,7 @@ nls/georgian-academy/Makefile nls/georgian-ps/Makefile nls/ibm-cp1133/Makefile + nls/ibm-cp866/Makefile nls/iscii-dev/Makefile nls/isiri-3342/Makefile nls/iso8859-1/Makefile diff -Naur libx11-1.0.3.cp866/nls/compose.dir.pre libx11-1.0.3/nls/compose.dir.pre --- libx11-1.0.3.cp866/nls/compose.dir.pre 2005-09-30 11:52:46 +0400 +++ libx11-1.0.3/nls/compose.dir.pre 2005-12-03 21:16:10 +0300 @@ -185,6 +185,7 @@ iso8859-15/Compose: pt_PT.ISO8859-15 iso8859-2/Compose: ro_RO.ISO8859-2 koi8-r/Compose: ru_RU.KOI8-R +ibm-cp866/Compose: ru_RU.CP866 iso8859-5/Compose: ru_RU.ISO8859-5 microsoft-cp1251/Compose: ru_RU.CP1251 koi8-u/Compose: ru_UA.KOI8-U diff -Naur libx11-1.0.3.cp866/nls/ibm-cp866/Compose.pre libx11-1.0.3/nls/ibm-cp866/Compose.pre --- libx11-1.0.3.cp866/nls/ibm-cp866/Compose.pre 1970-01-01 03:00:00 +0300 +++ libx11-1.0.3/nls/ibm-cp866/Compose.pre 2005-12-03 21:16:10 +0300 @@ -0,0 +1,1 @@ + diff -Naur libx11-1.0.3.cp866/nls/ibm-cp866/Makefile.am libx11-1.0.3/nls/ibm-cp866/Makefile.am --- libx11-1.0.3.cp866/nls/ibm-cp866/Makefile.am 1970-01-01 03:00:00 +0300 +++ libx11-1.0.3/nls/ibm-cp866/Makefile.am 2005-12-03 21:16:10 +0300 @@ -0,0 +1,3 @@ +x11thislocaledir = $(X11_LOCALEDATADIR)/ibm-cp866 + +include $(top_srcdir)/nls/localerules.in diff -Naur libx11-1.0.3.cp866/nls/ibm-cp866/XI18N_OBJS libx11-1.0.3/nls/ibm-cp866/XI18N_OBJS --- libx11-1.0.3.cp866/nls/ibm-cp866/XI18N_OBJS 1970-01-01 03:00:00 +0300 +++ libx11-1.0.3/nls/ibm-cp866/XI18N_OBJS 2005-12-03 21:16:10 +0300 @@ -0,0 +1,7 @@ +# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME +# +# XI18N objects table for ibm-cp866 locale +# +XLC common/xlcDef _XlcDefaultLoader # XLC_open +XIM common/ximcp _XimOpenIM _XimRegisterIMInstantiateCallback _XimUnRegisterIMInstantiateCallback # XIM_open XIM_register XIM_unregister +XOM common/xomGeneric _XomGenericOpenOM # XOM_open diff -Naur libx11-1.0.3.cp866/nls/ibm-cp866/XLC_LOCALE.pre libx11-1.0.3/nls/ibm-cp866/XLC_LOCALE.pre --- libx11-1.0.3.cp866/nls/ibm-cp866/XLC_LOCALE.pre 1970-01-01 03:00:00 +0300 +++ libx11-1.0.3/nls/ibm-cp866/XLC_LOCALE.pre 2005-12-03 21:16:10 +0300 @@ -0,0 +1,82 @@ +XCOMM $Xorg: ibm-cp866,v 1.3 2000/08/17 19:47:00 cpqbld Exp $ +XCOMM XLocale Database Sample for ibm-cp866. +XCOMM +XCOMM +XCOMM $XFree86: xc/nls/XLC_LOCALE/ibm-cp866,v 3.3 2000/12/01 17:43:03 dawes Exp $ + +XCOMM +XCOMM XLC_FONTSET category +XCOMM +XLC_FONTSET +XCOMM fs0 class (7 bit ASCII) +fs0 { + charset { + name ISO8859-1:GL + } + font { + primary CP866:GL + substitute ISO8859-1:GL + } +} +XCOMM fs1 class +fs1 { + charset CP866:GR + font CP866:GR +} +END XLC_FONTSET + +XCOMM +XCOMM XLC_CHARSET_DEFINE category +XCOMM +XLC_CHARSET_DEFINE +csd0 { + charset_name CP866 + side GR + length 1 + string_encoding False + sequence \x1b%/1 +} +END XLC_CHARSET_DEFINE + +XCOMM +XCOMM XLC_XLOCALE category +XCOMM +XLC_XLOCALE + +encoding_name CP866 +mb_cur_max 1 +state_depend_encoding False +#if WCHAR32 +wc_encoding_mask \x30000000 +wc_shift_bits 7 +#else +wc_encoding_mask \x00008080 +wc_shift_bits 8 +#endif + +#ifndef X_LOCALE +use_stdc_env True +#endif + +XCOMM cs0 class +cs0 { + side GL:Default + length 1 + wc_encoding \x00000000 + ct_encoding CP866:GL; ISO8859-1:GL +} + + +XCOMM cs1 class +cs1 { + side GR:Default + length 1 +#if WCHAR32 + wc_encoding \x30000000 +#else + wc_encoding \x00008080 +#endif + ct_encoding CP866:GR +} + +END XLC_XLOCALE diff -Naur libx11-1.0.3.cp866/nls/locale.dir.pre libx11-1.0.3/nls/locale.dir.pre --- libx11-1.0.3.cp866/nls/locale.dir.pre 2005-09-30 11:52:46 +0400 +++ libx11-1.0.3/nls/locale.dir.pre 2005-12-03 21:16:10 +0300 @@ -198,6 +198,7 @@ microsoft-cp1251/XLC_LOCALE: ru_RU.CP1251 koi8-r/XLC_LOCALE: ru_RU.KOI8-R koi8-u/XLC_LOCALE: ru_UA.KOI8-U +ibm-cp866/XLC_LOCALE: ru_RU.CP866 iso8859-1/XLC_LOCALE: rw_RW.ISO8859-1 iso8859-2/XLC_LOCALE: sh_YU.ISO8859-2 iso8859-2/XLC_LOCALE: sk_SK.ISO8859-2 diff -Naur libx11-1.0.3.cp866/nls/Makefile.am libx11-1.0.3/nls/Makefile.am --- libx11-1.0.3.cp866/nls/Makefile.am 2005-10-07 19:00:01 +0400 +++ libx11-1.0.3/nls/Makefile.am 2005-12-03 21:16:10 +0300 @@ -18,6 +18,7 @@ georgian-academy \ georgian-ps \ ibm-cp1133 \ + ibm-cp866 \ iscii-dev \ isiri-3342 \ iso8859-1 \ diff -Naur libx11-1.0.3.cp866/src/xlibi18n/lcUniConv/cp866.h libx11-1.0.3/src/xlibi18n/lcUniConv/cp866.h --- libx11-1.0.3.cp866/src/xlibi18n/lcUniConv/cp866.h 1970-01-01 03:00:00 +0300 +++ libx11-1.0.3/src/xlibi18n/lcUniConv/cp866.h 2005-12-03 21:16:10 +0300 @@ -0,0 +1,113 @@ + +/* + * CP866 + */ + +static const unsigned short cp866_2uni[128] = { + /* 0x80 */ + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, + /* 0x90 */ + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, + /* 0xa0 */ + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, + /* 0xb0 */ + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, + 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510, + /* 0xc0 */ + 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f, + 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567, + /* 0xd0 */ + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, + 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580, + /* 0xe0 */ + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, + /* 0xf0 */ + 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040e, 0x045e, + 0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0, +}; + +static int +cp866_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) +{ + unsigned char c = *s; + if (c < 0x80) + *pwc = (ucs4_t) c; + else + *pwc = (ucs4_t) cp866_2uni[c-0x80]; + return 1; +} + +static const unsigned char cp866_page00[24] = { + 0xff, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, /* 0xb0-0xb7 */ +}; +static const unsigned char cp866_page04[96] = { + 0x00, 0xf0, 0x00, 0x00, 0xf2, 0x00, 0x00, 0xf4, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x00, /* 0x08-0x0f */ + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 0x10-0x17 */ + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 0x18-0x1f */ + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 0x20-0x27 */ + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 0x28-0x2f */ + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* 0x30-0x37 */ + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* 0x38-0x3f */ + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0x40-0x47 */ + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* 0x48-0x4f */ + 0x00, 0xf1, 0x00, 0x00, 0xf3, 0x00, 0x00, 0xf5, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf7, 0x00, /* 0x58-0x5f */ +}; +static const unsigned char cp866_page22[8] = { + 0x00, 0xf9, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ +}; +static const unsigned char cp866_page25[168] = { + 0xc4, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0xd9, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0xcd, 0xba, 0xd5, 0xd6, 0xc9, 0xb8, 0xb7, 0xbb, /* 0x50-0x57 */ + 0xd4, 0xd3, 0xc8, 0xbe, 0xbd, 0xbc, 0xc6, 0xc7, /* 0x58-0x5f */ + 0xcc, 0xb5, 0xb6, 0xb9, 0xd1, 0xd2, 0xcb, 0xcf, /* 0x60-0x67 */ + 0xd0, 0xca, 0xd8, 0xd7, 0xce, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0xdb, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xde, 0xb0, 0xb1, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ +}; + +static int +cp866_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) +{ + unsigned char c = 0; + if (wc < 0x0080) { + *r = wc; + return 1; + } + else if (wc >= 0x00a0 && wc < 0x00b8) + c = cp866_page00[wc-0x00a0]; + else if (wc >= 0x0400 && wc < 0x0460) + c = cp866_page04[wc-0x0400]; + else if (wc == 0x2116) + c = 0xfc; + else if (wc >= 0x2218 && wc < 0x2220) + c = cp866_page22[wc-0x2218]; + else if (wc >= 0x2500 && wc < 0x25a8) + c = cp866_page25[wc-0x2500]; + if (c != 0) { + *r = c; + return 1; + } + return RET_ILSEQ; +} diff -Naur libx11-1.0.3.cp866/src/xlibi18n/lcUTF8.c libx11-1.0.3/src/xlibi18n/lcUTF8.c --- libx11-1.0.3.cp866/src/xlibi18n/lcUTF8.c 2005-05-14 02:53:44 +0400 +++ libx11-1.0.3/src/xlibi18n/lcUTF8.c 2005-12-03 21:16:10 +0300 @@ -189,6 +189,7 @@ #include "lcUniConv/koi8_r.h" #include "lcUniConv/koi8_u.h" #include "lcUniConv/koi8_c.h" +#include "lcUniConv/cp866.h" #include "lcUniConv/armscii_8.h" #include "lcUniConv/cp1133.h" #include "lcUniConv/mulelao.h" @@ -304,6 +305,9 @@ { "IBM-CP1133", NULLQUARK, cp1133_mbtowc, cp1133_wctomb }, + { "CP866", NULLQUARK, + cp866_mbtowc, cp866_wctomb + }, { "MULELAO-1", NULLQUARK, mulelao_mbtowc, mulelao_wctomb }, diff -Naur libx11-1.0.3.cp866/src/xlibi18n/Makefile.am libx11-1.0.3/src/xlibi18n/Makefile.am --- libx11-1.0.3.cp866/src/xlibi18n/Makefile.am 2005-10-07 19:00:01 +0400 +++ libx11-1.0.3/src/xlibi18n/Makefile.am 2005-12-03 21:16:10 +0300 @@ -95,6 +95,7 @@ lcUniConv/cp1251.h\ lcUniConv/cp1255.h\ lcUniConv/cp1256.h\ + lcUniConv/cp866.h \ lcUniConv/gb2312.h\ lcUniConv/georgian_academy.h\ lcUniConv/georgian_ps.h\ --- libx11-1.0.3/nls/locale.alias.pre.cp866 2006-07-13 17:50:10 +0400 +++ libx11-1.0.3/nls/locale.alias.pre 2006-11-11 16:54:17 +0300 @@ -898,6 +898,7 @@ ru_RU.microsoftcp1251: ru_RU.CP1251 ru_RU.microsoft-cp1251: ru_RU.CP1251 ru_RU.MICROSOFT-CP1251: ru_RU.CP1251 +ru_RU.cp866: ru_RU.CP866 #if defined(INCLUDE_ru_SU) XCOMM ru_SU is redundant now ru_SU: ru_RU.KOI8-R @@ -1057,6 +1058,7 @@ uk_UA.microsoft-cp1251: uk_UA.CP1251 uk_UA.MICROSOFT-CP1251: uk_UA.CP1251 uk_UA.utf8: uk_UA.UTF-8 +uk_UA.cp866: uk_UA.CP866 ur: ur_IN.UTF-8 ur_IN.utf8: ur_IN.UTF-8 ur_IN.UTF-8: ur_IN.UTF-8

<< Предыдущая ИНДЕКС Исправить src / Печать Следующая >>

Ваш комментарий
Имя:         
E-Mail:      
Заголовок:
Текст:





  Закладки на сайте
  Проследить за страницей
Created 1996-2017 by Maxim Chirkov  
ДобавитьРекламаВебмастеруГИД  
Hosting by Ihor