diff --git a/Makefile.in b/Makefile.in index 39c2fb5..1d5f62f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,6 +35,7 @@ SOURCES= \ $(wildcard src/core/keyboard/*.c) \ $(wildcard src/core/actions/*.c) \ $(wildcard src/core/toggles/*.c) \ + $(wildcard src/core/charset/*.c) \ $(wildcard src/core/ft/*.c) \ $(wildcard src/core/@OSNAME@/*.rc) \ $(wildcard src/core/@OSNAME@/*.c) \ diff --git a/lib3270.cbp b/lib3270.cbp index e5442c6..7b32af5 100644 --- a/lib3270.cbp +++ b/lib3270.cbp @@ -53,7 +53,22 @@ - + + + + + + + + + + + @@ -182,9 +197,6 @@ - - diff --git a/src/core/charset.c b/src/core/charset.c deleted file mode 100644 index 46799af..0000000 --- a/src/core/charset.c +++ /dev/null @@ -1,685 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como charset.c e possui - linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * - */ - -/** - * @file charset.c - * - * @brief This module handles character sets. - */ - -#include -#include -#include -#include -#include - -/* - * EBCDIC-to-Unicode translation tables. - * Each table maps EBCDIC codes X'41' through X'FE' to UCS-2. - * Other codes are mapped programmatically. - */ -#define UT_SIZE 190 -#define UT_OFFSET 0x41 - -/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ - -const unsigned short ebc2asc0[256] = -{ - /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20, - /*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /*40*/ 0x20, 0x20, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, - /*48*/ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, - /*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, - /*58*/ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, - /*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, - /*68*/ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, - /*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, - /*78*/ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, - /*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - /*88*/ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, - /*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - /*98*/ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, - /*a0*/ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - /*a8*/ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, - /*b0*/ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, - /*b8*/ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, - /*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - /*c8*/ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, - /*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, - /*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, - /*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - /*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, - /*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - /*f8*/ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x20 -}; - -static const unsigned short asc2ebc0[256] = -{ - /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*18*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, - /*28*/ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, - /*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - /*38*/ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, - /*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - /*48*/ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, - /*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, - /*58*/ 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d, - /*60*/ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - /*68*/ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, - /*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, - /*78*/ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x00, - /*80*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*88*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*90*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*98*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /*a0*/ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, - /*a8*/ 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc, - /*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, - /*b8*/ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, - /*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, - /*c8*/ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, - /*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, - /*d8*/ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59, - /*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, - /*e8*/ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, - /*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, - /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf -}; - -static const unsigned short asc2uc[UT_SIZE] = -{ - /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - /*48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - /*50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - /*58*/ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - /*60*/ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - /*68*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - /*70*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - /*78*/ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - /*80*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - /*88*/ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - /*90*/ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - /*98*/ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - /*a0*/ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - /*a8*/ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - /*b0*/ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - /*b8*/ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - /*c0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - /*c8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - /*d0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - /*d8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - /*e0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - /*e8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, - /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde -}; - -typedef struct _info -{ - const char * name; - unsigned long cgcsgid; - const unsigned short * chr; -} remap; - -static const remap charset[] = -{ - { - "us", - LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET, - (const unsigned short []) - { - 0x0000, 0x0000 - } - }, - - { - "bracket", - LIB3270_DEFAULT_CGEN|LIB3270_DEFAULT_CSET, - (const unsigned short []) - { - 0x00ad, '[', - 0x00ba, XK_Yacute, - 0x00bd, ']', - 0x00bb, XK_diaeresis, - 0x0000, 0x0000 - } - }, - - { - "cp500", - LIB3270_DEFAULT_CGEN|0x000001F4, - (const unsigned short []) - { - 0x004a, '[', - 0x004f, '!', - 0x005a, ']', - 0x005f, '^', - 0x00b0, XK_percent, - 0x00ba, XK_notsign, - 0x00bb, XK_bar - } - }, - - // Terminate list - { - NULL - } - -}; - -/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ - -static void copy_charset(const unsigned short *from, unsigned short *to) -{ - int f; - for(f=0;f < UT_SIZE;f++) - to[f+UT_OFFSET] = from[f]; -} - -LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, const char * display, unsigned long cgcsgid) -{ - int f; - - #define replace_pointer(x,v) if(x) { lib3270_free(x); }; x = strdup(v) - - replace_pointer(hSession->charset.host, host); - replace_pointer(hSession->charset.display,display); - - hSession->charset.cgcsgid = cgcsgid; - - memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); - memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc)); - - for(f=0;fcharset.asc2uc[f] = f; - - copy_charset(asc2uc,hSession->charset.asc2uc); - -} - -LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) -{ - int f; - - if(!name) - { - lib3270_reset_charset(hSession,"us","ISO-8859-1", LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET); - return 0; - } - - if(hSession->charset.host && !strcasecmp(name,hSession->charset.host)) - return 0; - - for(f=0;charset[f].name != NULL;f++) - { - if(!strcasecmp(name,charset[f].name)) - { - // Found required charset - int c; - - debug("%s: %s -> %s",__FUNCTION__,hSession->charset.host,charset[f].name); - - lib3270_reset_charset(hSession,charset[f].name,"ISO-8859-1", charset[f].cgcsgid); - - for(c=0;charset[f].chr[c];c+=2) - lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0); - - return 0; - } - } - - return ENOENT; - -} - -LIB3270_EXPORT const char * lib3270_get_default_charset(void) -{ - return "ISO-8859-1"; -} - -LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *hSession) -{ - return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; -} - -LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession) -{ - return hSession->charset.host; -} - -LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession) -{ - static const char * hChars = "0123456789ABCDEF"; - static const char * label = "Name:"; - - int f; - int margin_left = 5; - int baddr; - int chr; - int s,r; - const char *ptr; - - CHECK_SESSION_HANDLE(hSession); - - trace("%s","Showing charset table"); - - (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea)); - - baddr = margin_left+hSession->max.cols; - s = (hSession->max.cols * 0x11); - for(f=4;f<=0x0f;f++) - { - baddr += 2; - hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY; - hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; - hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0; - hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]]; - hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0; - } - - baddr = margin_left+(hSession->max.cols*2); - s = 0x1a; - for(f=0;f<=0x0f;f++) - { - hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY; - hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; - hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0; - hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]]; - hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0; - baddr += hSession->max.cols; - } - - chr = 0x40; - - for(f=0;f<0x0c;f++) - { - baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2; - for(r=0;r<=0x0f;r++) - { - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW; - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; - hSession->ea_buf[baddr].cs = 0; - hSession->ea_buf[baddr].cc = chr++; - hSession->ea_buf[baddr].gr = 0; - baddr += hSession->max.cols; - } - } - - baddr = margin_left+0x1d+(hSession->max.cols*2); - for(ptr=label;*ptr;ptr++) - { - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE; - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; - hSession->ea_buf[baddr].cs = 0; - hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr]; - hSession->ea_buf[baddr].gr = 0; - baddr++; - } - baddr++; - - for(ptr=hSession->charset.host;*ptr;ptr++) - { - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW; - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; - hSession->ea_buf[baddr].cs = 0; - hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr]; - hSession->ea_buf[baddr].gr = 0; - baddr++; - } - - hSession->cbk.display(hSession); - - return 0; -} - -LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, int sz) -{ - int f; - if(sz < 0) - sz = strlen((const char *) buffer); - - if(sz > 0) - { - for(f=0;fcharset.asc2ebc[buffer[f]]; - } - - return (const char *) buffer; -} - -LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, int sz) -{ - int f; - if(sz < 0) - sz = strlen((const char *) buffer); - - if(sz > 0) - { - for(f=0;fcharset.ebc2asc[buffer[f]]; - } - - return (const char *) buffer; -} - - -/// -/// @brief Process a single character definition. -/// -LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) -{ - // unsigned char cg; - CHECK_SESSION_HANDLE(hSession); - - // Ignore mappings of EBCDIC control codes and the space character. - if (ebc <= 0x40) - return; - - // If they want to map to a NULL or a blank, make it a one-way blank. - if (iso == 0x0) - iso = 0x20; - if (iso == 0x20) - one_way = True; - - if (iso <= 0xff) - { - if (scope == BOTH || scope == CS_ONLY) - { - if (ebc > 0x40) - { - hSession->charset.ebc2asc[ebc] = iso; - if (!one_way) - hSession->charset.asc2ebc[iso] = ebc; - } - } - - } -} - -LIB3270_EXPORT unsigned short lib3270_translate_char(const char *id) -{ - - static const struct - { - const char * name; - unsigned short keysym; - } - latin[] = - { - { "space", XK_space }, - { "exclam", XK_exclam }, - { "quotedbl", XK_quotedbl }, - { "numbersign", XK_numbersign }, - { "dollar", XK_dollar }, - { "percent", XK_percent }, - { "ampersand", XK_ampersand }, - { "apostrophe", XK_apostrophe }, - { "quoteright", XK_quoteright }, - { "parenleft", XK_parenleft }, - { "parenright", XK_parenright }, - { "asterisk", XK_asterisk }, - { "plus", XK_plus }, - { "comma", XK_comma }, - { "minus", XK_minus }, - { "period", XK_period }, - { "slash", XK_slash }, - { "0", XK_0 }, - { "1", XK_1 }, - { "2", XK_2 }, - { "3", XK_3 }, - { "4", XK_4 }, - { "5", XK_5 }, - { "6", XK_6 }, - { "7", XK_7 }, - { "8", XK_8 }, - { "9", XK_9 }, - { "colon", XK_colon }, - { "semicolon", XK_semicolon }, - { "less", XK_less }, - { "equal", XK_equal }, - { "greater", XK_greater }, - { "question", XK_question }, - { "at", XK_at }, - { "A", XK_A }, - { "B", XK_B }, - { "C", XK_C }, - { "D", XK_D }, - { "E", XK_E }, - { "F", XK_F }, - { "G", XK_G }, - { "H", XK_H }, - { "I", XK_I }, - { "J", XK_J }, - { "K", XK_K }, - { "L", XK_L }, - { "M", XK_M }, - { "N", XK_N }, - { "O", XK_O }, - { "P", XK_P }, - { "Q", XK_Q }, - { "R", XK_R }, - { "S", XK_S }, - { "T", XK_T }, - { "U", XK_U }, - { "V", XK_V }, - { "W", XK_W }, - { "X", XK_X }, - { "Y", XK_Y }, - { "Z", XK_Z }, - { "bracketleft", XK_bracketleft }, - { "backslash", XK_backslash }, - { "bracketright", XK_bracketright }, - { "asciicircum", XK_asciicircum }, - { "underscore", XK_underscore }, - { "grave", XK_grave }, - { "quoteleft", XK_quoteleft }, - { "a", XK_a }, - { "b", XK_b }, - { "c", XK_c }, - { "d", XK_d }, - { "e", XK_e }, - { "f", XK_f }, - { "g", XK_g }, - { "h", XK_h }, - { "i", XK_i }, - { "j", XK_j }, - { "k", XK_k }, - { "l", XK_l }, - { "m", XK_m }, - { "n", XK_n }, - { "o", XK_o }, - { "p", XK_p }, - { "q", XK_q }, - { "r", XK_r }, - { "s", XK_s }, - { "t", XK_t }, - { "u", XK_u }, - { "v", XK_v }, - { "w", XK_w }, - { "x", XK_x }, - { "y", XK_y }, - { "z", XK_z }, - { "braceleft", XK_braceleft }, - { "bar", XK_bar }, - { "braceright", XK_braceright }, - { "asciitilde", XK_asciitilde }, - { "nobreakspace", XK_nobreakspace }, - { "exclamdown", XK_exclamdown }, - { "cent", XK_cent }, - { "sterling", XK_sterling }, - { "currency", XK_currency }, - { "yen", XK_yen }, - { "brokenbar", XK_brokenbar }, - { "section", XK_section }, - { "diaeresis", XK_diaeresis }, - { "copyright", XK_copyright }, - { "ordfeminine", XK_ordfeminine }, - { "guillemotleft", XK_guillemotleft }, - { "notsign", XK_notsign }, - { "hyphen", XK_hyphen }, - { "registered", XK_registered }, - { "macron", XK_macron }, - { "degree", XK_degree }, - { "plusminus", XK_plusminus }, - { "twosuperior", XK_twosuperior }, - { "threesuperior", XK_threesuperior }, - { "acute", XK_acute }, - { "mu", XK_mu }, - { "paragraph", XK_paragraph }, - { "periodcentered", XK_periodcentered }, - { "cedilla", XK_cedilla }, - { "onesuperior", XK_onesuperior }, - { "masculine", XK_masculine }, - { "guillemotright", XK_guillemotright }, - { "onequarter", XK_onequarter }, - { "onehalf", XK_onehalf }, - { "threequarters", XK_threequarters }, - { "questiondown", XK_questiondown }, - { "Agrave", XK_Agrave }, - { "Aacute", XK_Aacute }, - { "Acircumflex", XK_Acircumflex }, - { "Atilde", XK_Atilde }, - { "Adiaeresis", XK_Adiaeresis }, - { "Aring", XK_Aring }, - { "AE", XK_AE }, - { "Ccedilla", XK_Ccedilla }, - { "Egrave", XK_Egrave }, - { "Eacute", XK_Eacute }, - { "Ecircumflex", XK_Ecircumflex }, - { "Ediaeresis", XK_Ediaeresis }, - { "Igrave", XK_Igrave }, - { "Iacute", XK_Iacute }, - { "Icircumflex", XK_Icircumflex }, - { "Idiaeresis", XK_Idiaeresis }, - { "ETH", XK_ETH }, - { "Eth", XK_Eth }, - { "Ntilde", XK_Ntilde }, - { "Ograve", XK_Ograve }, - { "Oacute", XK_Oacute }, - { "Ocircumflex", XK_Ocircumflex }, - { "Otilde", XK_Otilde }, - { "Odiaeresis", XK_Odiaeresis }, - { "multiply", XK_multiply }, - { "Ooblique", XK_Ooblique }, - { "Ugrave", XK_Ugrave }, - { "Uacute", XK_Uacute }, - { "Ucircumflex", XK_Ucircumflex }, - { "Udiaeresis", XK_Udiaeresis }, - { "Yacute", XK_Yacute }, - { "THORN", XK_THORN }, - { "Thorn", XK_Thorn }, - { "ssharp", XK_ssharp }, - { "agrave", XK_agrave }, - { "aacute", XK_aacute }, - { "acircumflex", XK_acircumflex }, - { "atilde", XK_atilde }, - { "adiaeresis", XK_adiaeresis }, - { "aring", XK_aring }, - { "ae", XK_ae }, - { "ccedilla", XK_ccedilla }, - { "egrave", XK_egrave }, - { "eacute", XK_eacute }, - { "ecircumflex", XK_ecircumflex }, - { "ediaeresis", XK_ediaeresis }, - { "igrave", XK_igrave }, - { "iacute", XK_iacute }, - { "icircumflex", XK_icircumflex }, - { "idiaeresis", XK_idiaeresis }, - { "eth", XK_eth }, - { "ntilde", XK_ntilde }, - { "ograve", XK_ograve }, - { "oacute", XK_oacute }, - { "ocircumflex", XK_ocircumflex }, - { "otilde", XK_otilde }, - { "odiaeresis", XK_odiaeresis }, - { "division", XK_division }, - { "oslash", XK_oslash }, - { "ugrave", XK_ugrave }, - { "uacute", XK_uacute }, - { "ucircumflex", XK_ucircumflex }, - { "udiaeresis", XK_udiaeresis }, - { "yacute", XK_yacute }, - { "thorn", XK_thorn }, - { "ydiaeresis", XK_ydiaeresis }, - - // The following are, umm, hacks to allow symbolic names for - // control codes. - #if !defined(_WIN32) - { "BackSpace", 0x08 }, - { "Tab", 0x09 }, - { "Linefeed", 0x0a }, - { "Return", 0x0d }, - { "Escape", 0x1b }, - { "Delete", 0x7f }, - #endif - }; - - size_t ix; - - if(strncasecmp(id,"0x",2) == 0) { - - unsigned int rc = 0; - - if(sscanf(id + 2, "%x", &rc) != 1) - { - errno = EINVAL; - return 0; - } - - return (unsigned short) rc; - - } - - for(ix=0;ix < (sizeof(latin)/sizeof(latin[0])); ix++) { - if(!strcasecmp(id,latin[ix].name)) - return latin[ix].keysym; - } - - if(strlen(id) != 1) - { - errno = EINVAL; - return 0; - } - - return (unsigned short) *id; - -} - - diff --git a/src/core/charset/charset.c b/src/core/charset/charset.c new file mode 100644 index 0000000..9e68cd8 --- /dev/null +++ b/src/core/charset/charset.c @@ -0,0 +1,271 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como charset.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + +/** + * @file charset.c + * + * @brief This module handles character sets. + */ + +#include +#include +#include +#include +#include + +/* + * EBCDIC-to-Unicode translation tables. + * Each table maps EBCDIC codes X'41' through X'FE' to UCS-2. + * Other codes are mapped programmatically. + */ +#define UT_SIZE 190 +#define UT_OFFSET 0x41 + +/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ + +const unsigned short ebc2asc0[256] = +{ + /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20, + /*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + /*40*/ 0x20, 0x20, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, + /*48*/ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, + /*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, + /*58*/ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac, + /*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, + /*68*/ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, + /*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, + /*78*/ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, + /*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + /*88*/ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, + /*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, + /*98*/ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, + /*a0*/ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + /*a8*/ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, + /*b0*/ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, + /*b8*/ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7, + /*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /*c8*/ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, + /*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, + /*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, + /*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + /*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, + /*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + /*f8*/ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x20 +}; + +static const unsigned short asc2ebc0[256] = +{ + /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*18*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, + /*28*/ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, + /*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + /*38*/ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, + /*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + /*48*/ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, + /*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, + /*58*/ 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d, + /*60*/ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*68*/ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + /*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, + /*78*/ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x00, + /*80*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*88*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*90*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*98*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /*a0*/ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, + /*a8*/ 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc, + /*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, + /*b8*/ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, + /*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, + /*c8*/ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, + /*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, + /*d8*/ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59, + /*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, + /*e8*/ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, + /*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, + /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf +}; + +static const unsigned short asc2uc[UT_SIZE] = +{ + /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /*48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + /*50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + /*58*/ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + /*60*/ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /*68*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + /*70*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + /*78*/ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + /*80*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*88*/ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + /*90*/ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + /*98*/ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + /*a0*/ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + /*a8*/ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + /*b0*/ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + /*b8*/ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + /*c0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + /*c8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + /*d0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + /*d8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + /*e0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + /*e8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7, + /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde +}; + +typedef struct _info +{ + const char * name; + unsigned long cgcsgid; + const unsigned short * chr; +} remap; + +static const remap charset[] = +{ + { + "us", + LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET, + (const unsigned short []) + { + 0x0000, 0x0000 + } + }, + + { + "bracket", + LIB3270_DEFAULT_CGEN|LIB3270_DEFAULT_CSET, + (const unsigned short []) + { + 0x00ad, '[', + 0x00ba, XK_Yacute, + 0x00bd, ']', + 0x00bb, XK_diaeresis, + 0x0000, 0x0000 + } + }, + + { + "cp500", + LIB3270_DEFAULT_CGEN|0x000001F4, + (const unsigned short []) + { + 0x004a, '[', + 0x004f, '!', + 0x005a, ']', + 0x005f, '^', + 0x00b0, XK_percent, + 0x00ba, XK_notsign, + 0x00bb, XK_bar + } + }, + + // Terminate list + { + NULL + } + +}; + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +static void copy_charset(const unsigned short *from, unsigned short *to) +{ + int f; + for(f=0;f < UT_SIZE;f++) + to[f+UT_OFFSET] = from[f]; +} + +LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, const char * display, unsigned long cgcsgid) +{ + int f; + + #define replace_pointer(x,v) if(x) { lib3270_free(x); }; x = strdup(v) + + replace_pointer(hSession->charset.host, host); + replace_pointer(hSession->charset.display,display); + + hSession->charset.cgcsgid = cgcsgid; + + memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc)); + memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc)); + + for(f=0;fcharset.asc2uc[f] = f; + + copy_charset(asc2uc,hSession->charset.asc2uc); + +} + +LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) +{ + int f; + + if(!name) + { + lib3270_reset_charset(hSession,"us","ISO-8859-1", LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET); + return 0; + } + + if(hSession->charset.host && !strcasecmp(name,hSession->charset.host)) + return 0; + + for(f=0;charset[f].name != NULL;f++) + { + if(!strcasecmp(name,charset[f].name)) + { + // Found required charset + int c; + + debug("%s: %s -> %s",__FUNCTION__,hSession->charset.host,charset[f].name); + + lib3270_reset_charset(hSession,charset[f].name,"ISO-8859-1", charset[f].cgcsgid); + + for(c=0;charset[f].chr[c];c+=2) + lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0); + + return 0; + } + } + + return ENOENT; + +} + diff --git a/src/core/charset/convert.c b/src/core/charset/convert.c new file mode 100644 index 0000000..2daf59c --- /dev/null +++ b/src/core/charset/convert.c @@ -0,0 +1,74 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como charset.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + +/** + * @file charset/convert.c + * + * @brief This module handles ebc<->asc conversion. + */ + +#include +#include +#include +#include + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, int sz) +{ + int f; + if(sz < 0) + sz = strlen((const char *) buffer); + + if(sz > 0) + { + for(f=0;fcharset.asc2ebc[buffer[f]]; + } + + return (const char *) buffer; +} + +LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, int sz) +{ + int f; + if(sz < 0) + sz = strlen((const char *) buffer); + + if(sz > 0) + { + for(f=0;fcharset.ebc2asc[buffer[f]]; + } + + return (const char *) buffer; +} + diff --git a/src/core/charset/getset.c b/src/core/charset/getset.c new file mode 100644 index 0000000..d995fb3 --- /dev/null +++ b/src/core/charset/getset.c @@ -0,0 +1,60 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como charset.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + +/** + * @file charset/getset.c + * + * @brief This module handles get/set the terminal character set. + */ + +#include +#include +#include +#include +#include + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +LIB3270_EXPORT const char * lib3270_get_default_charset(void) +{ + return "ISO-8859-1"; +} + +LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *hSession) +{ + return hSession->charset.display ? hSession->charset.display : "ISO-8859-1"; +} + +LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession) +{ + return hSession->charset.host; +} + diff --git a/src/core/charset/remap.c b/src/core/charset/remap.c new file mode 100644 index 0000000..a5bde92 --- /dev/null +++ b/src/core/charset/remap.c @@ -0,0 +1,326 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como charset.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + +/** + * @file charset/remap.c + * + * @brief + */ + +#include +#include +#include +#include +#include + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +/// +/// @brief Process a single character definition. +/// +LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) +{ + // unsigned char cg; + CHECK_SESSION_HANDLE(hSession); + + // Ignore mappings of EBCDIC control codes and the space character. + if (ebc <= 0x40) + return; + + // If they want to map to a NULL or a blank, make it a one-way blank. + if (iso == 0x0) + iso = 0x20; + if (iso == 0x20) + one_way = True; + + if (iso <= 0xff) + { + if (scope == BOTH || scope == CS_ONLY) + { + if (ebc > 0x40) + { + hSession->charset.ebc2asc[ebc] = iso; + if (!one_way) + hSession->charset.asc2ebc[iso] = ebc; + } + } + + } +} + +LIB3270_EXPORT unsigned short lib3270_translate_char(const char *id) +{ + + static const struct + { + const char * name; + unsigned short keysym; + } + latin[] = + { + { "space", XK_space }, + { "exclam", XK_exclam }, + { "quotedbl", XK_quotedbl }, + { "numbersign", XK_numbersign }, + { "dollar", XK_dollar }, + { "percent", XK_percent }, + { "ampersand", XK_ampersand }, + { "apostrophe", XK_apostrophe }, + { "quoteright", XK_quoteright }, + { "parenleft", XK_parenleft }, + { "parenright", XK_parenright }, + { "asterisk", XK_asterisk }, + { "plus", XK_plus }, + { "comma", XK_comma }, + { "minus", XK_minus }, + { "period", XK_period }, + { "slash", XK_slash }, + { "0", XK_0 }, + { "1", XK_1 }, + { "2", XK_2 }, + { "3", XK_3 }, + { "4", XK_4 }, + { "5", XK_5 }, + { "6", XK_6 }, + { "7", XK_7 }, + { "8", XK_8 }, + { "9", XK_9 }, + { "colon", XK_colon }, + { "semicolon", XK_semicolon }, + { "less", XK_less }, + { "equal", XK_equal }, + { "greater", XK_greater }, + { "question", XK_question }, + { "at", XK_at }, + { "A", XK_A }, + { "B", XK_B }, + { "C", XK_C }, + { "D", XK_D }, + { "E", XK_E }, + { "F", XK_F }, + { "G", XK_G }, + { "H", XK_H }, + { "I", XK_I }, + { "J", XK_J }, + { "K", XK_K }, + { "L", XK_L }, + { "M", XK_M }, + { "N", XK_N }, + { "O", XK_O }, + { "P", XK_P }, + { "Q", XK_Q }, + { "R", XK_R }, + { "S", XK_S }, + { "T", XK_T }, + { "U", XK_U }, + { "V", XK_V }, + { "W", XK_W }, + { "X", XK_X }, + { "Y", XK_Y }, + { "Z", XK_Z }, + { "bracketleft", XK_bracketleft }, + { "backslash", XK_backslash }, + { "bracketright", XK_bracketright }, + { "asciicircum", XK_asciicircum }, + { "underscore", XK_underscore }, + { "grave", XK_grave }, + { "quoteleft", XK_quoteleft }, + { "a", XK_a }, + { "b", XK_b }, + { "c", XK_c }, + { "d", XK_d }, + { "e", XK_e }, + { "f", XK_f }, + { "g", XK_g }, + { "h", XK_h }, + { "i", XK_i }, + { "j", XK_j }, + { "k", XK_k }, + { "l", XK_l }, + { "m", XK_m }, + { "n", XK_n }, + { "o", XK_o }, + { "p", XK_p }, + { "q", XK_q }, + { "r", XK_r }, + { "s", XK_s }, + { "t", XK_t }, + { "u", XK_u }, + { "v", XK_v }, + { "w", XK_w }, + { "x", XK_x }, + { "y", XK_y }, + { "z", XK_z }, + { "braceleft", XK_braceleft }, + { "bar", XK_bar }, + { "braceright", XK_braceright }, + { "asciitilde", XK_asciitilde }, + { "nobreakspace", XK_nobreakspace }, + { "exclamdown", XK_exclamdown }, + { "cent", XK_cent }, + { "sterling", XK_sterling }, + { "currency", XK_currency }, + { "yen", XK_yen }, + { "brokenbar", XK_brokenbar }, + { "section", XK_section }, + { "diaeresis", XK_diaeresis }, + { "copyright", XK_copyright }, + { "ordfeminine", XK_ordfeminine }, + { "guillemotleft", XK_guillemotleft }, + { "notsign", XK_notsign }, + { "hyphen", XK_hyphen }, + { "registered", XK_registered }, + { "macron", XK_macron }, + { "degree", XK_degree }, + { "plusminus", XK_plusminus }, + { "twosuperior", XK_twosuperior }, + { "threesuperior", XK_threesuperior }, + { "acute", XK_acute }, + { "mu", XK_mu }, + { "paragraph", XK_paragraph }, + { "periodcentered", XK_periodcentered }, + { "cedilla", XK_cedilla }, + { "onesuperior", XK_onesuperior }, + { "masculine", XK_masculine }, + { "guillemotright", XK_guillemotright }, + { "onequarter", XK_onequarter }, + { "onehalf", XK_onehalf }, + { "threequarters", XK_threequarters }, + { "questiondown", XK_questiondown }, + { "Agrave", XK_Agrave }, + { "Aacute", XK_Aacute }, + { "Acircumflex", XK_Acircumflex }, + { "Atilde", XK_Atilde }, + { "Adiaeresis", XK_Adiaeresis }, + { "Aring", XK_Aring }, + { "AE", XK_AE }, + { "Ccedilla", XK_Ccedilla }, + { "Egrave", XK_Egrave }, + { "Eacute", XK_Eacute }, + { "Ecircumflex", XK_Ecircumflex }, + { "Ediaeresis", XK_Ediaeresis }, + { "Igrave", XK_Igrave }, + { "Iacute", XK_Iacute }, + { "Icircumflex", XK_Icircumflex }, + { "Idiaeresis", XK_Idiaeresis }, + { "ETH", XK_ETH }, + { "Eth", XK_Eth }, + { "Ntilde", XK_Ntilde }, + { "Ograve", XK_Ograve }, + { "Oacute", XK_Oacute }, + { "Ocircumflex", XK_Ocircumflex }, + { "Otilde", XK_Otilde }, + { "Odiaeresis", XK_Odiaeresis }, + { "multiply", XK_multiply }, + { "Ooblique", XK_Ooblique }, + { "Ugrave", XK_Ugrave }, + { "Uacute", XK_Uacute }, + { "Ucircumflex", XK_Ucircumflex }, + { "Udiaeresis", XK_Udiaeresis }, + { "Yacute", XK_Yacute }, + { "THORN", XK_THORN }, + { "Thorn", XK_Thorn }, + { "ssharp", XK_ssharp }, + { "agrave", XK_agrave }, + { "aacute", XK_aacute }, + { "acircumflex", XK_acircumflex }, + { "atilde", XK_atilde }, + { "adiaeresis", XK_adiaeresis }, + { "aring", XK_aring }, + { "ae", XK_ae }, + { "ccedilla", XK_ccedilla }, + { "egrave", XK_egrave }, + { "eacute", XK_eacute }, + { "ecircumflex", XK_ecircumflex }, + { "ediaeresis", XK_ediaeresis }, + { "igrave", XK_igrave }, + { "iacute", XK_iacute }, + { "icircumflex", XK_icircumflex }, + { "idiaeresis", XK_idiaeresis }, + { "eth", XK_eth }, + { "ntilde", XK_ntilde }, + { "ograve", XK_ograve }, + { "oacute", XK_oacute }, + { "ocircumflex", XK_ocircumflex }, + { "otilde", XK_otilde }, + { "odiaeresis", XK_odiaeresis }, + { "division", XK_division }, + { "oslash", XK_oslash }, + { "ugrave", XK_ugrave }, + { "uacute", XK_uacute }, + { "ucircumflex", XK_ucircumflex }, + { "udiaeresis", XK_udiaeresis }, + { "yacute", XK_yacute }, + { "thorn", XK_thorn }, + { "ydiaeresis", XK_ydiaeresis }, + + // The following are, umm, hacks to allow symbolic names for + // control codes. + #if !defined(_WIN32) + { "BackSpace", 0x08 }, + { "Tab", 0x09 }, + { "Linefeed", 0x0a }, + { "Return", 0x0d }, + { "Escape", 0x1b }, + { "Delete", 0x7f }, + #endif + }; + + size_t ix; + + if(strncasecmp(id,"0x",2) == 0) { + + unsigned int rc = 0; + + if(sscanf(id + 2, "%x", &rc) != 1) + { + errno = EINVAL; + return 0; + } + + return (unsigned short) rc; + + } + + for(ix=0;ix < (sizeof(latin)/sizeof(latin[0])); ix++) { + if(!strcasecmp(id,latin[ix].name)) + return latin[ix].keysym; + } + + if(strlen(id) != 1) + { + errno = EINVAL; + return 0; + } + + return (unsigned short) *id; + +} diff --git a/src/core/charset/utf8.c b/src/core/charset/utf8.c new file mode 100644 index 0000000..ae99cb0 --- /dev/null +++ b/src/core/charset/utf8.c @@ -0,0 +1,359 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como utf8.c e possui 514 linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) + * + */ + +/** + * @file utf8.c + * @brief 3270 Terminal Emulator UTF-8 conversions + */ + +#include +// #include "api.h" + +#include "popupsc.h" +#include "utf8c.h" + +// char *locale_codeset = CN; + +// static int utf8_ix = -1; + +// static Boolean is_utf8 = False; +#if defined(X3270_DBCS) /*[*/ +static Boolean is_gb18030 = False; +#endif /*]*/ + +/* Various types of 8-bit character sets we understand. */ +enum UTF_IX { + /* Real translations from 8-bit encodings to UTF-8. */ + U_ISO8859_1, + U_ISO8859_2, + U_ISO8859_7, + U_ISO8859_8, + U_ISO8859_9, + U_ISO8859_11, + U_ISO8859_15, + U_KOI8_R, + +#if defined(X3270_DBCS) /*[*/ + /* Multi-byte expansions of non-UTF-8 encodings. */ + PSEUDO_GB18030, +#endif /*]*/ + + U_MAX +}; + +/* + * Names of the above (real) character sets. These are the names used in + * displayCharset resources. + */ /* +static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[] + "iso8859-1", + "iso8859-2", + "iso8859-7", + "iso8859-8", + "iso8859-9", + "iso8859-11", + "iso8859-15", + "koi8-r", + CN +}; +*/ + +/* + * UTF-8 translation tables. + * These are used to convert code points 0xa0 through 0xff to UTF-8. + * + * Note that this could be done much more generally with the iconv library + * or the ICU library, but there is no guarantee that either is available or + * properly configured. + */ /* +#define HI_SIZE 96 +static char *utf8_tab[U_MAX][96] = { + + // iso8859-1 + { + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", + "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", + "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf", + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", + "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93", + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", + "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f", + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", + "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", + "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf" +}, +// iso8859-2 +{ + "\xc2\xa0", "\xc4\x84", "\xcb\x98", "\xc5\x81", + "\xc2\xa4", "\xc4\xbd", "\xc5\x9a", "\xc2\xa7", + "\xc2\xa8", "\xc5\xa0", "\xc5\x9e", "\xc5\xa4", + "\xc5\xb9", "\xc2\xad", "\xc5\xbd", "\xc5\xbb", + "\xc2\xb0", "\xc4\x85", "\xcb\x9b", "\xc5\x82", + "\xc2\xb4", "\xc4\xbe", "\xc5\x9b", "\xcb\x87", + "\xc2\xb8", "\xc5\xa1", "\xc5\x9f", "\xc5\xa5", + "\xc5\xba", "\xcb\x9d", "\xc5\xbe", "\xc5\xbc", + "\xc5\x94", "\xc3\x81", "\xc3\x82", "\xc4\x82", + "\xc3\x84", "\xc4\xb9", "\xc4\x86", "\xc3\x87", + "\xc4\x8c", "\xc3\x89", "\xc4\x98", "\xc3\x8b", + "\xc4\x9a", "\xc3\x8d", "\xc3\x8e", "\xc4\x8e", + "\xc4\x90", "\xc5\x83", "\xc5\x87", "\xc3\x93", + "\xc3\x94", "\xc5\x90", "\xc3\x96", "\xc3\x97", + "\xc5\x98", "\xc5\xae", "\xc3\x9a", "\xc5\xb0", + "\xc3\x9c", "\xc3\x9d", "\xc5\xa2", "\xc3\x9f", + "\xc5\x95", "\xc3\xa1", "\xc3\xa2", "\xc4\x83", + "\xc3\xa4", "\xc4\xba", "\xc4\x87", "\xc3\xa7", + "\xc4\x8d", "\xc3\xa9", "\xc4\x99", "\xc3\xab", + "\xc4\x9b", "\xc3\xad", "\xc3\xae", "\xc4\x8f", + "\xc4\x91", "\xc5\x84", "\xc5\x88", "\xc3\xb3", + "\xc3\xb4", "\xc5\x91", "\xc3\xb6", "\xc3\xb7", + "\xc5\x99", "\xc5\xaf", "\xc3\xba", "\xc5\xb1", + "\xc3\xbc", "\xc3\xbd", "\xc5\xa3", "\xcb\x99" +}, +// iso8859-7 +{ + "\xc2\xa0", "\xe2\x80\x98", "\xe2\x80\x99", "\xc2\xa3", + "\xe2\x82\xac", "\xe2\x82\xaf", "\xc2\xa6", "\xc2\xa7", + "\xc2\xa8", "\xc2\xa9", "\xcd\xba", "\xc2\xab", + "\xc2\xac", "\xc2\xad", " ", "\xe2\x80\x95", + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", + "\xce\x84", "\xce\x85", "\xce\x86", "\xc2\xb7", + "\xce\x88", "\xce\x89", "\xce\x8a", "\xc2\xbb", + "\xce\x8c", "\xc2\xbd", "\xce\x8e", "\xce\x8f", + "\xce\x90", "\xce\x91", "\xce\x92", "\xce\x93", + "\xce\x94", "\xce\x95", "\xce\x96", "\xce\x97", + "\xce\x98", "\xce\x99", "\xce\x9a", "\xce\x9b", + "\xce\x9c", "\xce\x9d", "\xce\x9e", "\xce\x9f", + "\xce\xa0", "\xce\xa1", " ", "\xce\xa3", + "\xce\xa4", "\xce\xa5", "\xce\xa6", "\xce\xa7", + "\xce\xa8", "\xce\xa9", "\xce\xaa", "\xce\xab", + "\xce\xac", "\xce\xad", "\xce\xae", "\xce\xaf", + "\xce\xb0", "\xce\xb1", "\xce\xb2", "\xce\xb3", + "\xce\xb4", "\xce\xb5", "\xce\xb6", "\xce\xb7", + "\xce\xb8", "\xce\xb9", "\xce\xba", "\xce\xbb", + "\xce\xbc", "\xce\xbd", "\xce\xbe", "\xce\xbf", + "\xcf\x80", "\xcf\x81", "\xcf\x82", "\xcf\x83", + "\xcf\x84", "\xcf\x85", "\xcf\x86", "\xcf\x87", + "\xcf\x88", "\xcf\x89", "\xcf\x8a", "\xcf\x8b", + "\xcf\x8c", "\xcf\x8d", "\xcf\x8e", " " +}, +// iso8859-8 +{ + "\xc2\xa0", " ", "\xc2\xa2", "\xc2\xa3", + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", + "\xc2\xa8", "\xc2\xa9", "\xc3\x97", "\xc2\xab", + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", + "\xc2\xb8", "\xc2\xb9", "\xc3\xb7", "\xc2\xbb", + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", " ", + " ", " ", " ", "\xe2\x80\x97", + "\xd7\x90", "\xd7\x91", "\xd7\x92", "\xd7\x93", + "\xd7\x94", "\xd7\x95", "\xd7\x96", "\xd7\x97", + "\xd7\x98", "\xd7\x99", "\xd7\x9a", "\xd7\x9b", + "\xd7\x9c", "\xd7\x9d", "\xd7\x9e", "\xd7\x9f", + "\xd7\xa0", "\xd7\xa1", "\xd7\xa2", "\xd7\xa3", + "\xd7\xa4", "\xd7\xa5", "\xd7\xa6", "\xd7\xa7", + "\xd7\xa8", "\xd7\xa9", "\xd7\xaa", " ", + " ", "\xe2\x80\x8e", "\xe2\x80\x8f", " " +}, +// iso8859-9 +{ + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", + "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", + "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf", + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", + "\xc4\x9e", "\xc3\x91", "\xc3\x92", "\xc3\x93", + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", + "\xc3\x9c", "\xc4\xb0", "\xc5\x9e", "\xc3\x9f", + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", + "\xc4\x9f", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", + "\xc3\xbc", "\xc4\xb1", "\xc5\x9f", "\xc3\xbf" +}, +// iso8859-11 +{ + "\xc2\xa0", "\xe0\xb8\x81", "\xe0\xb8\x82", "\xe0\xb8\x83", + "\xe0\xb8\x84", "\xe0\xb8\x85", "\xe0\xb8\x86", "\xe0\xb8\x87", + "\xe0\xb8\x88", "\xe0\xb8\x89", "\xe0\xb8\x8a", "\xe0\xb8\x8b", + "\xe0\xb8\x8c", "\xe0\xb8\x8d", "\xe0\xb8\x8e", "\xe0\xb8\x8f", + "\xe0\xb8\x90", "\xe0\xb8\x91", "\xe0\xb8\x92", "\xe0\xb8\x93", + "\xe0\xb8\x94", "\xe0\xb8\x95", "\xe0\xb8\x96", "\xe0\xb8\x97", + "\xe0\xb8\x98", "\xe0\xb8\x99", "\xe0\xb8\x9a", "\xe0\xb8\x9b", + "\xe0\xb8\x9c", "\xe0\xb8\x9d", "\xe0\xb8\x9e", "\xe0\xb8\x9f", + "\xe0\xb8\xa0", "\xe0\xb8\xa1", "\xe0\xb8\xa2", "\xe0\xb8\xa3", + "\xe0\xb8\xa4", "\xe0\xb8\xa5", "\xe0\xb8\xa6", "\xe0\xb8\xa7", + "\xe0\xb8\xa8", "\xe0\xb8\xa9", "\xe0\xb8\xaa", "\xe0\xb8\xab", + "\xe0\xb8\xac", "\xe0\xb8\xad", "\xe0\xb8\xae", "\xe0\xb8\xaf", + "\xe0\xb8\xb0", "\xe0\xb8\xb1", "\xe0\xb8\xb2", "\xe0\xb8\xb3", + "\xe0\xb8\xb4", "\xe0\xb8\xb5", "\xe0\xb8\xb6", "\xe0\xb8\xb7", + "\xe0\xb8\xb8", "\xe0\xb8\xb9", "\xe0\xb8\xba", " ", + " ", " ", " ", "\xe0\xb8\xbf", + "\xe0\xb9\x80", "\xe0\xb9\x81", "\xe0\xb9\x82", "\xe0\xb9\x83", + "\xe0\xb9\x84", "\xe0\xb9\x85", "\xe0\xb9\x86", "\xe0\xb9\x87", + "\xe0\xb9\x88", "\xe0\xb9\x89", "\xe0\xb9\x8a", "\xe0\xb9\x8b", + "\xe0\xb9\x8c", "\xe0\xb9\x8d", "\xe0\xb9\x8e", "\xe0\xb9\x8f", + "\xe0\xb9\x90", "\xe0\xb9\x91", "\xe0\xb9\x92", "\xe0\xb9\x93", + "\xe0\xb9\x94", "\xe0\xb9\x95", "\xe0\xb9\x96", "\xe0\xb9\x97", + "\xe0\xb9\x98", "\xe0\xb9\x99", "\xe0\xb9\x9a", "\xe0\xb9\x9b", + " ", " ", " ", " " +}, +// iso8859-15 +{ + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", + "\xe2\x82\xac", "\xc2\xa5", "\xc5\xa0", "\xc2\xa7", + "\xc5\xa1", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", + "\xc5\xbd", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", + "\xc5\xbe", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", + "\xc5\x92", "\xc5\x93", "\xc5\xb8", "\xc2\xbf", + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", + "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93", + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", + "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f", + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", + "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", + "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf" +}, +// koi8-r +{ + "\xe2\x95\x90", "\xe2\x95\x91", "\xe2\x95\x92", "\xd1\x91", + "\xe2\x95\x93", "\xe2\x95\x94", "\xe2\x95\x95", "\xe2\x95\x96", + "\xe2\x95\x97", "\xe2\x95\x98", "\xe2\x95\x99", "\xe2\x95\x9a", + "\xe2\x95\x9b", "\xe2\x95\x9c", "\xe2\x95\x9d", "\xe2\x95\x9e", + "\xe2\x95\x9f", "\xe2\x95\xa0", "\xe2\x95\xa1", "\xd0\x81", + "\xe2\x95\xa2", "\xe2\x95\xa3", "\xe2\x95\xa4", "\xe2\x95\xa5", + "\xe2\x95\xa6", "\xe2\x95\xa7", "\xe2\x95\xa8", "\xe2\x95\xa9", + "\xe2\x95\xaa", "\xe2\x95\xab", "\xe2\x95\xac", "\xc2\xa9", + "\xd1\x8e", "\xd0\xb0", "\xd0\xb1", "\xd1\x86", + "\xd0\xb4", "\xd0\xb5", "\xd1\x84", "\xd0\xb3", + "\xd1\x85", "\xd0\xb8", "\xd0\xb9", "\xd0\xba", + "\xd0\xbb", "\xd0\xbc", "\xd0\xbd", "\xd0\xbe", + "\xd0\xbf", "\xd1\x8f", "\xd1\x80", "\xd1\x81", + "\xd1\x82", "\xd1\x83", "\xd0\xb6", "\xd0\xb2", + "\xd1\x8c", "\xd1\x8b", "\xd0\xb7", "\xd1\x88", + "\xd1\x8d", "\xd1\x89", "\xd1\x87", "\xd1\x8a", + "\xd0\xae", "\xd0\x90", "\xd0\x91", "\xd0\xa6", + "\xd0\x94", "\xd0\x95", "\xd0\xa4", "\xd0\x93", + "\xd0\xa5", "\xd0\x98", "\xd0\x99", "\xd0\x9a", + "\xd0\x9b", "\xd0\x9c", "\xd0\x9d", "\xd0\x9e", + "\xd0\x9f", "\xd0\xaf", "\xd0\xa0", "\xd0\xa1", + "\xd0\xa2", "\xd0\xa3", "\xd0\x96", "\xd0\x92", + "\xd0\xac", "\xd0\xab", "\xd0\x97", "\xd0\xa8", + "\xd0\xad", "\xd0\xa9", "\xd0\xa7", "\xd0\xaa" +}, +#if defined(X3270_DBCS) +// pseudo-gb18030 - not actually a UTF-8 expansion +{ + "\x81\x30\x84\x32", "\x81\x30\x84\x33", "\x81\x30\x84\x34", "\x81\x30\x84\x35", + "\xa1\xe8", "\x81\x30\x84\x36", "\x81\x30\x84\x37", "\xa1\xec", + "\xa1\xa7", "\x81\x30\x84\x38", "\x81\x30\x84\x39", "\x81\x30\x85\x30", + "\x81\x30\x85\x31", "\x81\x30\x85\x32", "\x81\x30\x85\x33", "\x81\x30\x85\x34", + "\xa1\xe3", "\xa1\xc0", "\x81\x30\x85\x35", "\x81\x30\x85\x36", + "\x81\x30\x85\x37", "\x81\x30\x85\x38", "\x81\x30\x85\x39", "\xa1\xa4", + "\x81\x30\x86\x30", "\x81\x30\x86\x31", "\x81\x30\x86\x32", "\x81\x30\x86\x33", + "\x81\x30\x86\x34", "\x81\x30\x86\x35", "\x81\x30\x86\x36", "\x81\x30\x86\x37", + "\x81\x30\x86\x38", "\x81\x30\x86\x39", "\x81\x30\x87\x30", "\x81\x30\x87\x31", + "\x81\x30\x87\x32", "\x81\x30\x87\x33", "\x81\x30\x87\x34", "\x81\x30\x87\x35", + "\x81\x30\x87\x36", "\x81\x30\x87\x37", "\x81\x30\x87\x38", "\x81\x30\x87\x39", + "\x81\x30\x88\x30", "\x81\x30\x88\x31", "\x81\x30\x88\x32", "\x81\x30\x88\x33", + "\x81\x30\x88\x34", "\x81\x30\x88\x35", "\x81\x30\x88\x36", "\x81\x30\x88\x37", + "\x81\x30\x88\x38", "\x81\x30\x88\x39", "\x81\x30\x89\x30", "\xa1\xc1", + "\x81\x30\x89\x31", "\x81\x30\x89\x32", "\x81\x30\x89\x33", "\x81\x30\x89\x34", + "\x81\x30\x89\x35", "\x81\x30\x89\x36", "\x81\x30\x89\x37", "\x81\x30\x89\x38", + "\xa8\xa4", "\xa8\xa2", "\x81\x30\x89\x39", "\x81\x30\x8a\x30", + "\x81\x30\x8a\x31", "\x81\x30\x8a\x32", "\x81\x30\x8a\x33", "\x81\x30\x8a\x34", + "\xa8\xa8", "\xa8\xa6", "\xa8\xba", "\x81\x30\x8a\x35", + "\xa8\xac", "\xa8\xaa", "\x81\x30\x8a\x36", "\x81\x30\x8a\x37", + "\x81\x30\x8a\x38", "\x81\x30\x8a\x39", "\xa8\xb0", "\xa8\xae", + "\x81\x30\x8b\x30", "\x81\x30\x8b\x31", "\x81\x30\x8b\x32", "\xa1\xc2", + "\x81\x30\x8b\x33", "\xa8\xb4", "\xa8\xb2", "\x81\x30\x8b\x34", + "\xa8\xb9", "\x81\x30\x8b\x35", "\x81\x30\x8b\x36", "\x81\x30\x8b\x37" +} +#endif +}; +*/ +/* + * Look up a multi-byte UTF-8 string and return its value in the 'implied' + * character set. + * Returns 0 if the lookup fails. + */ +unsigned char utf8_lookup(char GNUC_UNUSED(*mbs), enum ulfail *fail, int GNUC_UNUSED(*consumed)) +{ + if (fail != NULL) + *fail = ULFAIL_NOUTF8; + + return 0; +} diff --git a/src/core/charset/view.c b/src/core/charset/view.c new file mode 100644 index 0000000..dc839f7 --- /dev/null +++ b/src/core/charset/view.c @@ -0,0 +1,131 @@ +/* + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como charset.c e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * + */ + +/** + * @file charset/view.c + * + * @brief This module shows the charset table. + */ + +#include +#include +#include +#include + +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ + +LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession) +{ + static const char * hChars = "0123456789ABCDEF"; + static const char * label = "Name:"; + + int f; + int margin_left = 5; + int baddr; + int chr; + int s,r; + const char *ptr; + + CHECK_SESSION_HANDLE(hSession); + + trace("%s","Showing charset table"); + + (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea)); + + baddr = margin_left+hSession->max.cols; + s = (hSession->max.cols * 0x11); + for(f=4;f<=0x0f;f++) + { + baddr += 2; + hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY; + hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; + hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0; + hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]]; + hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0; + } + + baddr = margin_left+(hSession->max.cols*2); + s = 0x1a; + for(f=0;f<=0x0f;f++) + { + hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY; + hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; + hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0; + hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]]; + hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0; + baddr += hSession->max.cols; + } + + chr = 0x40; + + for(f=0;f<0x0c;f++) + { + baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2; + for(r=0;r<=0x0f;r++) + { + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW; + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; + hSession->ea_buf[baddr].cs = 0; + hSession->ea_buf[baddr].cc = chr++; + hSession->ea_buf[baddr].gr = 0; + baddr += hSession->max.cols; + } + } + + baddr = margin_left+0x1d+(hSession->max.cols*2); + for(ptr=label;*ptr;ptr++) + { + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE; + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; + hSession->ea_buf[baddr].cs = 0; + hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr]; + hSession->ea_buf[baddr].gr = 0; + baddr++; + } + baddr++; + + for(ptr=hSession->charset.host;*ptr;ptr++) + { + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW; + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK; + hSession->ea_buf[baddr].cs = 0; + hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr]; + hSession->ea_buf[baddr].gr = 0; + baddr++; + } + + hSession->cbk.display(hSession); + + return 0; +} + + + diff --git a/src/core/utf8.c b/src/core/utf8.c deleted file mode 100644 index ae99cb0..0000000 --- a/src/core/utf8.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como utf8.c e possui 514 linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) - * - */ - -/** - * @file utf8.c - * @brief 3270 Terminal Emulator UTF-8 conversions - */ - -#include -// #include "api.h" - -#include "popupsc.h" -#include "utf8c.h" - -// char *locale_codeset = CN; - -// static int utf8_ix = -1; - -// static Boolean is_utf8 = False; -#if defined(X3270_DBCS) /*[*/ -static Boolean is_gb18030 = False; -#endif /*]*/ - -/* Various types of 8-bit character sets we understand. */ -enum UTF_IX { - /* Real translations from 8-bit encodings to UTF-8. */ - U_ISO8859_1, - U_ISO8859_2, - U_ISO8859_7, - U_ISO8859_8, - U_ISO8859_9, - U_ISO8859_11, - U_ISO8859_15, - U_KOI8_R, - -#if defined(X3270_DBCS) /*[*/ - /* Multi-byte expansions of non-UTF-8 encodings. */ - PSEUDO_GB18030, -#endif /*]*/ - - U_MAX -}; - -/* - * Names of the above (real) character sets. These are the names used in - * displayCharset resources. - */ /* -static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[] - "iso8859-1", - "iso8859-2", - "iso8859-7", - "iso8859-8", - "iso8859-9", - "iso8859-11", - "iso8859-15", - "koi8-r", - CN -}; -*/ - -/* - * UTF-8 translation tables. - * These are used to convert code points 0xa0 through 0xff to UTF-8. - * - * Note that this could be done much more generally with the iconv library - * or the ICU library, but there is no guarantee that either is available or - * properly configured. - */ /* -#define HI_SIZE 96 -static char *utf8_tab[U_MAX][96] = { - - // iso8859-1 - { - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", - "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", - "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf", - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", - "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93", - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", - "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f", - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", - "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", - "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf" -}, -// iso8859-2 -{ - "\xc2\xa0", "\xc4\x84", "\xcb\x98", "\xc5\x81", - "\xc2\xa4", "\xc4\xbd", "\xc5\x9a", "\xc2\xa7", - "\xc2\xa8", "\xc5\xa0", "\xc5\x9e", "\xc5\xa4", - "\xc5\xb9", "\xc2\xad", "\xc5\xbd", "\xc5\xbb", - "\xc2\xb0", "\xc4\x85", "\xcb\x9b", "\xc5\x82", - "\xc2\xb4", "\xc4\xbe", "\xc5\x9b", "\xcb\x87", - "\xc2\xb8", "\xc5\xa1", "\xc5\x9f", "\xc5\xa5", - "\xc5\xba", "\xcb\x9d", "\xc5\xbe", "\xc5\xbc", - "\xc5\x94", "\xc3\x81", "\xc3\x82", "\xc4\x82", - "\xc3\x84", "\xc4\xb9", "\xc4\x86", "\xc3\x87", - "\xc4\x8c", "\xc3\x89", "\xc4\x98", "\xc3\x8b", - "\xc4\x9a", "\xc3\x8d", "\xc3\x8e", "\xc4\x8e", - "\xc4\x90", "\xc5\x83", "\xc5\x87", "\xc3\x93", - "\xc3\x94", "\xc5\x90", "\xc3\x96", "\xc3\x97", - "\xc5\x98", "\xc5\xae", "\xc3\x9a", "\xc5\xb0", - "\xc3\x9c", "\xc3\x9d", "\xc5\xa2", "\xc3\x9f", - "\xc5\x95", "\xc3\xa1", "\xc3\xa2", "\xc4\x83", - "\xc3\xa4", "\xc4\xba", "\xc4\x87", "\xc3\xa7", - "\xc4\x8d", "\xc3\xa9", "\xc4\x99", "\xc3\xab", - "\xc4\x9b", "\xc3\xad", "\xc3\xae", "\xc4\x8f", - "\xc4\x91", "\xc5\x84", "\xc5\x88", "\xc3\xb3", - "\xc3\xb4", "\xc5\x91", "\xc3\xb6", "\xc3\xb7", - "\xc5\x99", "\xc5\xaf", "\xc3\xba", "\xc5\xb1", - "\xc3\xbc", "\xc3\xbd", "\xc5\xa3", "\xcb\x99" -}, -// iso8859-7 -{ - "\xc2\xa0", "\xe2\x80\x98", "\xe2\x80\x99", "\xc2\xa3", - "\xe2\x82\xac", "\xe2\x82\xaf", "\xc2\xa6", "\xc2\xa7", - "\xc2\xa8", "\xc2\xa9", "\xcd\xba", "\xc2\xab", - "\xc2\xac", "\xc2\xad", " ", "\xe2\x80\x95", - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", - "\xce\x84", "\xce\x85", "\xce\x86", "\xc2\xb7", - "\xce\x88", "\xce\x89", "\xce\x8a", "\xc2\xbb", - "\xce\x8c", "\xc2\xbd", "\xce\x8e", "\xce\x8f", - "\xce\x90", "\xce\x91", "\xce\x92", "\xce\x93", - "\xce\x94", "\xce\x95", "\xce\x96", "\xce\x97", - "\xce\x98", "\xce\x99", "\xce\x9a", "\xce\x9b", - "\xce\x9c", "\xce\x9d", "\xce\x9e", "\xce\x9f", - "\xce\xa0", "\xce\xa1", " ", "\xce\xa3", - "\xce\xa4", "\xce\xa5", "\xce\xa6", "\xce\xa7", - "\xce\xa8", "\xce\xa9", "\xce\xaa", "\xce\xab", - "\xce\xac", "\xce\xad", "\xce\xae", "\xce\xaf", - "\xce\xb0", "\xce\xb1", "\xce\xb2", "\xce\xb3", - "\xce\xb4", "\xce\xb5", "\xce\xb6", "\xce\xb7", - "\xce\xb8", "\xce\xb9", "\xce\xba", "\xce\xbb", - "\xce\xbc", "\xce\xbd", "\xce\xbe", "\xce\xbf", - "\xcf\x80", "\xcf\x81", "\xcf\x82", "\xcf\x83", - "\xcf\x84", "\xcf\x85", "\xcf\x86", "\xcf\x87", - "\xcf\x88", "\xcf\x89", "\xcf\x8a", "\xcf\x8b", - "\xcf\x8c", "\xcf\x8d", "\xcf\x8e", " " -}, -// iso8859-8 -{ - "\xc2\xa0", " ", "\xc2\xa2", "\xc2\xa3", - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", - "\xc2\xa8", "\xc2\xa9", "\xc3\x97", "\xc2\xab", - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", - "\xc2\xb8", "\xc2\xb9", "\xc3\xb7", "\xc2\xbb", - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", " ", - " ", " ", " ", "\xe2\x80\x97", - "\xd7\x90", "\xd7\x91", "\xd7\x92", "\xd7\x93", - "\xd7\x94", "\xd7\x95", "\xd7\x96", "\xd7\x97", - "\xd7\x98", "\xd7\x99", "\xd7\x9a", "\xd7\x9b", - "\xd7\x9c", "\xd7\x9d", "\xd7\x9e", "\xd7\x9f", - "\xd7\xa0", "\xd7\xa1", "\xd7\xa2", "\xd7\xa3", - "\xd7\xa4", "\xd7\xa5", "\xd7\xa6", "\xd7\xa7", - "\xd7\xa8", "\xd7\xa9", "\xd7\xaa", " ", - " ", "\xe2\x80\x8e", "\xe2\x80\x8f", " " -}, -// iso8859-9 -{ - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7", - "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", - "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf", - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", - "\xc4\x9e", "\xc3\x91", "\xc3\x92", "\xc3\x93", - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", - "\xc3\x9c", "\xc4\xb0", "\xc5\x9e", "\xc3\x9f", - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", - "\xc4\x9f", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", - "\xc3\xbc", "\xc4\xb1", "\xc5\x9f", "\xc3\xbf" -}, -// iso8859-11 -{ - "\xc2\xa0", "\xe0\xb8\x81", "\xe0\xb8\x82", "\xe0\xb8\x83", - "\xe0\xb8\x84", "\xe0\xb8\x85", "\xe0\xb8\x86", "\xe0\xb8\x87", - "\xe0\xb8\x88", "\xe0\xb8\x89", "\xe0\xb8\x8a", "\xe0\xb8\x8b", - "\xe0\xb8\x8c", "\xe0\xb8\x8d", "\xe0\xb8\x8e", "\xe0\xb8\x8f", - "\xe0\xb8\x90", "\xe0\xb8\x91", "\xe0\xb8\x92", "\xe0\xb8\x93", - "\xe0\xb8\x94", "\xe0\xb8\x95", "\xe0\xb8\x96", "\xe0\xb8\x97", - "\xe0\xb8\x98", "\xe0\xb8\x99", "\xe0\xb8\x9a", "\xe0\xb8\x9b", - "\xe0\xb8\x9c", "\xe0\xb8\x9d", "\xe0\xb8\x9e", "\xe0\xb8\x9f", - "\xe0\xb8\xa0", "\xe0\xb8\xa1", "\xe0\xb8\xa2", "\xe0\xb8\xa3", - "\xe0\xb8\xa4", "\xe0\xb8\xa5", "\xe0\xb8\xa6", "\xe0\xb8\xa7", - "\xe0\xb8\xa8", "\xe0\xb8\xa9", "\xe0\xb8\xaa", "\xe0\xb8\xab", - "\xe0\xb8\xac", "\xe0\xb8\xad", "\xe0\xb8\xae", "\xe0\xb8\xaf", - "\xe0\xb8\xb0", "\xe0\xb8\xb1", "\xe0\xb8\xb2", "\xe0\xb8\xb3", - "\xe0\xb8\xb4", "\xe0\xb8\xb5", "\xe0\xb8\xb6", "\xe0\xb8\xb7", - "\xe0\xb8\xb8", "\xe0\xb8\xb9", "\xe0\xb8\xba", " ", - " ", " ", " ", "\xe0\xb8\xbf", - "\xe0\xb9\x80", "\xe0\xb9\x81", "\xe0\xb9\x82", "\xe0\xb9\x83", - "\xe0\xb9\x84", "\xe0\xb9\x85", "\xe0\xb9\x86", "\xe0\xb9\x87", - "\xe0\xb9\x88", "\xe0\xb9\x89", "\xe0\xb9\x8a", "\xe0\xb9\x8b", - "\xe0\xb9\x8c", "\xe0\xb9\x8d", "\xe0\xb9\x8e", "\xe0\xb9\x8f", - "\xe0\xb9\x90", "\xe0\xb9\x91", "\xe0\xb9\x92", "\xe0\xb9\x93", - "\xe0\xb9\x94", "\xe0\xb9\x95", "\xe0\xb9\x96", "\xe0\xb9\x97", - "\xe0\xb9\x98", "\xe0\xb9\x99", "\xe0\xb9\x9a", "\xe0\xb9\x9b", - " ", " ", " ", " " -}, -// iso8859-15 -{ - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3", - "\xe2\x82\xac", "\xc2\xa5", "\xc5\xa0", "\xc2\xa7", - "\xc5\xa1", "\xc2\xa9", "\xc2\xaa", "\xc2\xab", - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf", - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3", - "\xc5\xbd", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7", - "\xc5\xbe", "\xc2\xb9", "\xc2\xba", "\xc2\xbb", - "\xc5\x92", "\xc5\x93", "\xc5\xb8", "\xc2\xbf", - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83", - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87", - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b", - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f", - "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93", - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97", - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b", - "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f", - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3", - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7", - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab", - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf", - "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3", - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7", - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb", - "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf" -}, -// koi8-r -{ - "\xe2\x95\x90", "\xe2\x95\x91", "\xe2\x95\x92", "\xd1\x91", - "\xe2\x95\x93", "\xe2\x95\x94", "\xe2\x95\x95", "\xe2\x95\x96", - "\xe2\x95\x97", "\xe2\x95\x98", "\xe2\x95\x99", "\xe2\x95\x9a", - "\xe2\x95\x9b", "\xe2\x95\x9c", "\xe2\x95\x9d", "\xe2\x95\x9e", - "\xe2\x95\x9f", "\xe2\x95\xa0", "\xe2\x95\xa1", "\xd0\x81", - "\xe2\x95\xa2", "\xe2\x95\xa3", "\xe2\x95\xa4", "\xe2\x95\xa5", - "\xe2\x95\xa6", "\xe2\x95\xa7", "\xe2\x95\xa8", "\xe2\x95\xa9", - "\xe2\x95\xaa", "\xe2\x95\xab", "\xe2\x95\xac", "\xc2\xa9", - "\xd1\x8e", "\xd0\xb0", "\xd0\xb1", "\xd1\x86", - "\xd0\xb4", "\xd0\xb5", "\xd1\x84", "\xd0\xb3", - "\xd1\x85", "\xd0\xb8", "\xd0\xb9", "\xd0\xba", - "\xd0\xbb", "\xd0\xbc", "\xd0\xbd", "\xd0\xbe", - "\xd0\xbf", "\xd1\x8f", "\xd1\x80", "\xd1\x81", - "\xd1\x82", "\xd1\x83", "\xd0\xb6", "\xd0\xb2", - "\xd1\x8c", "\xd1\x8b", "\xd0\xb7", "\xd1\x88", - "\xd1\x8d", "\xd1\x89", "\xd1\x87", "\xd1\x8a", - "\xd0\xae", "\xd0\x90", "\xd0\x91", "\xd0\xa6", - "\xd0\x94", "\xd0\x95", "\xd0\xa4", "\xd0\x93", - "\xd0\xa5", "\xd0\x98", "\xd0\x99", "\xd0\x9a", - "\xd0\x9b", "\xd0\x9c", "\xd0\x9d", "\xd0\x9e", - "\xd0\x9f", "\xd0\xaf", "\xd0\xa0", "\xd0\xa1", - "\xd0\xa2", "\xd0\xa3", "\xd0\x96", "\xd0\x92", - "\xd0\xac", "\xd0\xab", "\xd0\x97", "\xd0\xa8", - "\xd0\xad", "\xd0\xa9", "\xd0\xa7", "\xd0\xaa" -}, -#if defined(X3270_DBCS) -// pseudo-gb18030 - not actually a UTF-8 expansion -{ - "\x81\x30\x84\x32", "\x81\x30\x84\x33", "\x81\x30\x84\x34", "\x81\x30\x84\x35", - "\xa1\xe8", "\x81\x30\x84\x36", "\x81\x30\x84\x37", "\xa1\xec", - "\xa1\xa7", "\x81\x30\x84\x38", "\x81\x30\x84\x39", "\x81\x30\x85\x30", - "\x81\x30\x85\x31", "\x81\x30\x85\x32", "\x81\x30\x85\x33", "\x81\x30\x85\x34", - "\xa1\xe3", "\xa1\xc0", "\x81\x30\x85\x35", "\x81\x30\x85\x36", - "\x81\x30\x85\x37", "\x81\x30\x85\x38", "\x81\x30\x85\x39", "\xa1\xa4", - "\x81\x30\x86\x30", "\x81\x30\x86\x31", "\x81\x30\x86\x32", "\x81\x30\x86\x33", - "\x81\x30\x86\x34", "\x81\x30\x86\x35", "\x81\x30\x86\x36", "\x81\x30\x86\x37", - "\x81\x30\x86\x38", "\x81\x30\x86\x39", "\x81\x30\x87\x30", "\x81\x30\x87\x31", - "\x81\x30\x87\x32", "\x81\x30\x87\x33", "\x81\x30\x87\x34", "\x81\x30\x87\x35", - "\x81\x30\x87\x36", "\x81\x30\x87\x37", "\x81\x30\x87\x38", "\x81\x30\x87\x39", - "\x81\x30\x88\x30", "\x81\x30\x88\x31", "\x81\x30\x88\x32", "\x81\x30\x88\x33", - "\x81\x30\x88\x34", "\x81\x30\x88\x35", "\x81\x30\x88\x36", "\x81\x30\x88\x37", - "\x81\x30\x88\x38", "\x81\x30\x88\x39", "\x81\x30\x89\x30", "\xa1\xc1", - "\x81\x30\x89\x31", "\x81\x30\x89\x32", "\x81\x30\x89\x33", "\x81\x30\x89\x34", - "\x81\x30\x89\x35", "\x81\x30\x89\x36", "\x81\x30\x89\x37", "\x81\x30\x89\x38", - "\xa8\xa4", "\xa8\xa2", "\x81\x30\x89\x39", "\x81\x30\x8a\x30", - "\x81\x30\x8a\x31", "\x81\x30\x8a\x32", "\x81\x30\x8a\x33", "\x81\x30\x8a\x34", - "\xa8\xa8", "\xa8\xa6", "\xa8\xba", "\x81\x30\x8a\x35", - "\xa8\xac", "\xa8\xaa", "\x81\x30\x8a\x36", "\x81\x30\x8a\x37", - "\x81\x30\x8a\x38", "\x81\x30\x8a\x39", "\xa8\xb0", "\xa8\xae", - "\x81\x30\x8b\x30", "\x81\x30\x8b\x31", "\x81\x30\x8b\x32", "\xa1\xc2", - "\x81\x30\x8b\x33", "\xa8\xb4", "\xa8\xb2", "\x81\x30\x8b\x34", - "\xa8\xb9", "\x81\x30\x8b\x35", "\x81\x30\x8b\x36", "\x81\x30\x8b\x37" -} -#endif -}; -*/ -/* - * Look up a multi-byte UTF-8 string and return its value in the 'implied' - * character set. - * Returns 0 if the lookup fails. - */ -unsigned char utf8_lookup(char GNUC_UNUSED(*mbs), enum ulfail *fail, int GNUC_UNUSED(*consumed)) -{ - if (fail != NULL) - *fail = ULFAIL_NOUTF8; - - return 0; -} -- libgit2 0.21.2