Commit 13102f834c26109424753d2aeeb91140254bf4e0

Authored by Perry Werneck
1 parent b1eba98b

Refactoring charset translation sources.

Makefile.in
... ... @@ -35,6 +35,7 @@ SOURCES= \
35 35 $(wildcard src/core/keyboard/*.c) \
36 36 $(wildcard src/core/actions/*.c) \
37 37 $(wildcard src/core/toggles/*.c) \
  38 + $(wildcard src/core/charset/*.c) \
38 39 $(wildcard src/core/ft/*.c) \
39 40 $(wildcard src/core/@OSNAME@/*.rc) \
40 41 $(wildcard src/core/@OSNAME@/*.c) \
... ...
lib3270.cbp
... ... @@ -53,7 +53,22 @@
53 53 <Unit filename="src/core/bounds.c">
54 54 <Option compilerVar="CC" />
55 55 </Unit>
56   - <Unit filename="src/core/charset.c">
  56 + <Unit filename="src/core/charset/charset.c">
  57 + <Option compilerVar="CC" />
  58 + </Unit>
  59 + <Unit filename="src/core/charset/convert.c">
  60 + <Option compilerVar="CC" />
  61 + </Unit>
  62 + <Unit filename="src/core/charset/getset.c">
  63 + <Option compilerVar="CC" />
  64 + </Unit>
  65 + <Unit filename="src/core/charset/remap.c">
  66 + <Option compilerVar="CC" />
  67 + </Unit>
  68 + <Unit filename="src/core/charset/utf8.c">
  69 + <Option compilerVar="CC" />
  70 + </Unit>
  71 + <Unit filename="src/core/charset/view.c">
57 72 <Option compilerVar="CC" />
58 73 </Unit>
59 74 <Unit filename="src/core/connect.c">
... ... @@ -182,9 +197,6 @@
182 197 <Unit filename="src/core/trace_ds.c">
183 198 <Option compilerVar="CC" />
184 199 </Unit>
185   - <Unit filename="src/core/utf8.c">
186   - <Option compilerVar="CC" />
187   - </Unit>
188 200 <Unit filename="src/core/util.c">
189 201 <Option compilerVar="CC" />
190 202 </Unit>
... ...
src/core/charset.c
... ... @@ -1,685 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como charset.c e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - *
30   - */
31   -
32   -/**
33   - * @file charset.c
34   - *
35   - * @brief This module handles character sets.
36   - */
37   -
38   -#include <lib3270-internals.h>
39   -#include <X11keysym.h>
40   -#include <lib3270/charset.h>
41   -#include <lib3270/log.h>
42   -#include <lib3270/trace.h>
43   -
44   -/*
45   - * EBCDIC-to-Unicode translation tables.
46   - * Each table maps EBCDIC codes X'41' through X'FE' to UCS-2.
47   - * Other codes are mapped programmatically.
48   - */
49   -#define UT_SIZE 190
50   -#define UT_OFFSET 0x41
51   -
52   -/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/
53   -
54   -const unsigned short ebc2asc0[256] =
55   -{
56   - /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
57   - /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
58   - /*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
59   - /*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20,
60   - /*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
61   - /*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
62   - /*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
63   - /*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
64   - /*40*/ 0x20, 0x20, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
65   - /*48*/ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
66   - /*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
67   - /*58*/ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac,
68   - /*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
69   - /*68*/ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
70   - /*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
71   - /*78*/ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
72   - /*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
73   - /*88*/ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
74   - /*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
75   - /*98*/ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
76   - /*a0*/ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
77   - /*a8*/ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,
78   - /*b0*/ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
79   - /*b8*/ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7,
80   - /*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
81   - /*c8*/ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
82   - /*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
83   - /*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff,
84   - /*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
85   - /*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
86   - /*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
87   - /*f8*/ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x20
88   -};
89   -
90   -static const unsigned short asc2ebc0[256] =
91   -{
92   - /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93   - /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94   - /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
95   - /*18*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
96   - /*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
97   - /*28*/ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
98   - /*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
99   - /*38*/ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
100   - /*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
101   - /*48*/ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
102   - /*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
103   - /*58*/ 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d,
104   - /*60*/ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
105   - /*68*/ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
106   - /*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
107   - /*78*/ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x00,
108   - /*80*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109   - /*88*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110   - /*90*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111   - /*98*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
112   - /*a0*/ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
113   - /*a8*/ 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc,
114   - /*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
115   - /*b8*/ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
116   - /*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
117   - /*c8*/ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
118   - /*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
119   - /*d8*/ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59,
120   - /*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
121   - /*e8*/ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
122   - /*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
123   - /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf
124   -};
125   -
126   -static const unsigned short asc2uc[UT_SIZE] =
127   -{
128   - /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
129   - /*48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
130   - /*50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
131   - /*58*/ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
132   - /*60*/ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
133   - /*68*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
134   - /*70*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
135   - /*78*/ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
136   - /*80*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
137   - /*88*/ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
138   - /*90*/ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
139   - /*98*/ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
140   - /*a0*/ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
141   - /*a8*/ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
142   - /*b0*/ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
143   - /*b8*/ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
144   - /*c0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
145   - /*c8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
146   - /*d0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
147   - /*d8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
148   - /*e0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
149   - /*e8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
150   - /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7,
151   - /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde
152   -};
153   -
154   -typedef struct _info
155   -{
156   - const char * name;
157   - unsigned long cgcsgid;
158   - const unsigned short * chr;
159   -} remap;
160   -
161   -static const remap charset[] =
162   -{
163   - {
164   - "us",
165   - LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET,
166   - (const unsigned short [])
167   - {
168   - 0x0000, 0x0000
169   - }
170   - },
171   -
172   - {
173   - "bracket",
174   - LIB3270_DEFAULT_CGEN|LIB3270_DEFAULT_CSET,
175   - (const unsigned short [])
176   - {
177   - 0x00ad, '[',
178   - 0x00ba, XK_Yacute,
179   - 0x00bd, ']',
180   - 0x00bb, XK_diaeresis,
181   - 0x0000, 0x0000
182   - }
183   - },
184   -
185   - {
186   - "cp500",
187   - LIB3270_DEFAULT_CGEN|0x000001F4,
188   - (const unsigned short [])
189   - {
190   - 0x004a, '[',
191   - 0x004f, '!',
192   - 0x005a, ']',
193   - 0x005f, '^',
194   - 0x00b0, XK_percent,
195   - 0x00ba, XK_notsign,
196   - 0x00bb, XK_bar
197   - }
198   - },
199   -
200   - // Terminate list
201   - {
202   - NULL
203   - }
204   -
205   -};
206   -
207   -/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
208   -
209   -static void copy_charset(const unsigned short *from, unsigned short *to)
210   -{
211   - int f;
212   - for(f=0;f < UT_SIZE;f++)
213   - to[f+UT_OFFSET] = from[f];
214   -}
215   -
216   -LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, const char * display, unsigned long cgcsgid)
217   -{
218   - int f;
219   -
220   - #define replace_pointer(x,v) if(x) { lib3270_free(x); }; x = strdup(v)
221   -
222   - replace_pointer(hSession->charset.host, host);
223   - replace_pointer(hSession->charset.display,display);
224   -
225   - hSession->charset.cgcsgid = cgcsgid;
226   -
227   - memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc));
228   - memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc));
229   -
230   - for(f=0;f<UT_OFFSET;f++)
231   - hSession->charset.asc2uc[f] = f;
232   -
233   - copy_charset(asc2uc,hSession->charset.asc2uc);
234   -
235   -}
236   -
237   -LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
238   -{
239   - int f;
240   -
241   - if(!name)
242   - {
243   - lib3270_reset_charset(hSession,"us","ISO-8859-1", LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET);
244   - return 0;
245   - }
246   -
247   - if(hSession->charset.host && !strcasecmp(name,hSession->charset.host))
248   - return 0;
249   -
250   - for(f=0;charset[f].name != NULL;f++)
251   - {
252   - if(!strcasecmp(name,charset[f].name))
253   - {
254   - // Found required charset
255   - int c;
256   -
257   - debug("%s: %s -> %s",__FUNCTION__,hSession->charset.host,charset[f].name);
258   -
259   - lib3270_reset_charset(hSession,charset[f].name,"ISO-8859-1", charset[f].cgcsgid);
260   -
261   - for(c=0;charset[f].chr[c];c+=2)
262   - lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0);
263   -
264   - return 0;
265   - }
266   - }
267   -
268   - return ENOENT;
269   -
270   -}
271   -
272   -LIB3270_EXPORT const char * lib3270_get_default_charset(void)
273   -{
274   - return "ISO-8859-1";
275   -}
276   -
277   -LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *hSession)
278   -{
279   - return hSession->charset.display ? hSession->charset.display : "ISO-8859-1";
280   -}
281   -
282   -LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession)
283   -{
284   - return hSession->charset.host;
285   -}
286   -
287   -LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
288   -{
289   - static const char * hChars = "0123456789ABCDEF";
290   - static const char * label = "Name:";
291   -
292   - int f;
293   - int margin_left = 5;
294   - int baddr;
295   - int chr;
296   - int s,r;
297   - const char *ptr;
298   -
299   - CHECK_SESSION_HANDLE(hSession);
300   -
301   - trace("%s","Showing charset table");
302   -
303   - (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea));
304   -
305   - baddr = margin_left+hSession->max.cols;
306   - s = (hSession->max.cols * 0x11);
307   - for(f=4;f<=0x0f;f++)
308   - {
309   - baddr += 2;
310   - hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY;
311   - hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
312   - hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
313   - hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
314   - hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
315   - }
316   -
317   - baddr = margin_left+(hSession->max.cols*2);
318   - s = 0x1a;
319   - for(f=0;f<=0x0f;f++)
320   - {
321   - hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY;
322   - hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
323   - hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
324   - hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
325   - hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
326   - baddr += hSession->max.cols;
327   - }
328   -
329   - chr = 0x40;
330   -
331   - for(f=0;f<0x0c;f++)
332   - {
333   - baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2;
334   - for(r=0;r<=0x0f;r++)
335   - {
336   - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
337   - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
338   - hSession->ea_buf[baddr].cs = 0;
339   - hSession->ea_buf[baddr].cc = chr++;
340   - hSession->ea_buf[baddr].gr = 0;
341   - baddr += hSession->max.cols;
342   - }
343   - }
344   -
345   - baddr = margin_left+0x1d+(hSession->max.cols*2);
346   - for(ptr=label;*ptr;ptr++)
347   - {
348   - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE;
349   - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
350   - hSession->ea_buf[baddr].cs = 0;
351   - hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr];
352   - hSession->ea_buf[baddr].gr = 0;
353   - baddr++;
354   - }
355   - baddr++;
356   -
357   - for(ptr=hSession->charset.host;*ptr;ptr++)
358   - {
359   - hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
360   - hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
361   - hSession->ea_buf[baddr].cs = 0;
362   - hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr];
363   - hSession->ea_buf[baddr].gr = 0;
364   - baddr++;
365   - }
366   -
367   - hSession->cbk.display(hSession);
368   -
369   - return 0;
370   -}
371   -
372   -LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, int sz)
373   -{
374   - int f;
375   - if(sz < 0)
376   - sz = strlen((const char *) buffer);
377   -
378   - if(sz > 0)
379   - {
380   - for(f=0;f<sz;f++)
381   - buffer[f] = hSession->charset.asc2ebc[buffer[f]];
382   - }
383   -
384   - return (const char *) buffer;
385   -}
386   -
387   -LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, int sz)
388   -{
389   - int f;
390   - if(sz < 0)
391   - sz = strlen((const char *) buffer);
392   -
393   - if(sz > 0)
394   - {
395   - for(f=0;f<sz;f++)
396   - buffer[f] = hSession->charset.ebc2asc[buffer[f]];
397   - }
398   -
399   - return (const char *) buffer;
400   -}
401   -
402   -
403   -///
404   -/// @brief Process a single character definition.
405   -///
406   -LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way)
407   -{
408   - // unsigned char cg;
409   - CHECK_SESSION_HANDLE(hSession);
410   -
411   - // Ignore mappings of EBCDIC control codes and the space character.
412   - if (ebc <= 0x40)
413   - return;
414   -
415   - // If they want to map to a NULL or a blank, make it a one-way blank.
416   - if (iso == 0x0)
417   - iso = 0x20;
418   - if (iso == 0x20)
419   - one_way = True;
420   -
421   - if (iso <= 0xff)
422   - {
423   - if (scope == BOTH || scope == CS_ONLY)
424   - {
425   - if (ebc > 0x40)
426   - {
427   - hSession->charset.ebc2asc[ebc] = iso;
428   - if (!one_way)
429   - hSession->charset.asc2ebc[iso] = ebc;
430   - }
431   - }
432   -
433   - }
434   -}
435   -
436   -LIB3270_EXPORT unsigned short lib3270_translate_char(const char *id)
437   -{
438   -
439   - static const struct
440   - {
441   - const char * name;
442   - unsigned short keysym;
443   - }
444   - latin[] =
445   - {
446   - { "space", XK_space },
447   - { "exclam", XK_exclam },
448   - { "quotedbl", XK_quotedbl },
449   - { "numbersign", XK_numbersign },
450   - { "dollar", XK_dollar },
451   - { "percent", XK_percent },
452   - { "ampersand", XK_ampersand },
453   - { "apostrophe", XK_apostrophe },
454   - { "quoteright", XK_quoteright },
455   - { "parenleft", XK_parenleft },
456   - { "parenright", XK_parenright },
457   - { "asterisk", XK_asterisk },
458   - { "plus", XK_plus },
459   - { "comma", XK_comma },
460   - { "minus", XK_minus },
461   - { "period", XK_period },
462   - { "slash", XK_slash },
463   - { "0", XK_0 },
464   - { "1", XK_1 },
465   - { "2", XK_2 },
466   - { "3", XK_3 },
467   - { "4", XK_4 },
468   - { "5", XK_5 },
469   - { "6", XK_6 },
470   - { "7", XK_7 },
471   - { "8", XK_8 },
472   - { "9", XK_9 },
473   - { "colon", XK_colon },
474   - { "semicolon", XK_semicolon },
475   - { "less", XK_less },
476   - { "equal", XK_equal },
477   - { "greater", XK_greater },
478   - { "question", XK_question },
479   - { "at", XK_at },
480   - { "A", XK_A },
481   - { "B", XK_B },
482   - { "C", XK_C },
483   - { "D", XK_D },
484   - { "E", XK_E },
485   - { "F", XK_F },
486   - { "G", XK_G },
487   - { "H", XK_H },
488   - { "I", XK_I },
489   - { "J", XK_J },
490   - { "K", XK_K },
491   - { "L", XK_L },
492   - { "M", XK_M },
493   - { "N", XK_N },
494   - { "O", XK_O },
495   - { "P", XK_P },
496   - { "Q", XK_Q },
497   - { "R", XK_R },
498   - { "S", XK_S },
499   - { "T", XK_T },
500   - { "U", XK_U },
501   - { "V", XK_V },
502   - { "W", XK_W },
503   - { "X", XK_X },
504   - { "Y", XK_Y },
505   - { "Z", XK_Z },
506   - { "bracketleft", XK_bracketleft },
507   - { "backslash", XK_backslash },
508   - { "bracketright", XK_bracketright },
509   - { "asciicircum", XK_asciicircum },
510   - { "underscore", XK_underscore },
511   - { "grave", XK_grave },
512   - { "quoteleft", XK_quoteleft },
513   - { "a", XK_a },
514   - { "b", XK_b },
515   - { "c", XK_c },
516   - { "d", XK_d },
517   - { "e", XK_e },
518   - { "f", XK_f },
519   - { "g", XK_g },
520   - { "h", XK_h },
521   - { "i", XK_i },
522   - { "j", XK_j },
523   - { "k", XK_k },
524   - { "l", XK_l },
525   - { "m", XK_m },
526   - { "n", XK_n },
527   - { "o", XK_o },
528   - { "p", XK_p },
529   - { "q", XK_q },
530   - { "r", XK_r },
531   - { "s", XK_s },
532   - { "t", XK_t },
533   - { "u", XK_u },
534   - { "v", XK_v },
535   - { "w", XK_w },
536   - { "x", XK_x },
537   - { "y", XK_y },
538   - { "z", XK_z },
539   - { "braceleft", XK_braceleft },
540   - { "bar", XK_bar },
541   - { "braceright", XK_braceright },
542   - { "asciitilde", XK_asciitilde },
543   - { "nobreakspace", XK_nobreakspace },
544   - { "exclamdown", XK_exclamdown },
545   - { "cent", XK_cent },
546   - { "sterling", XK_sterling },
547   - { "currency", XK_currency },
548   - { "yen", XK_yen },
549   - { "brokenbar", XK_brokenbar },
550   - { "section", XK_section },
551   - { "diaeresis", XK_diaeresis },
552   - { "copyright", XK_copyright },
553   - { "ordfeminine", XK_ordfeminine },
554   - { "guillemotleft", XK_guillemotleft },
555   - { "notsign", XK_notsign },
556   - { "hyphen", XK_hyphen },
557   - { "registered", XK_registered },
558   - { "macron", XK_macron },
559   - { "degree", XK_degree },
560   - { "plusminus", XK_plusminus },
561   - { "twosuperior", XK_twosuperior },
562   - { "threesuperior", XK_threesuperior },
563   - { "acute", XK_acute },
564   - { "mu", XK_mu },
565   - { "paragraph", XK_paragraph },
566   - { "periodcentered", XK_periodcentered },
567   - { "cedilla", XK_cedilla },
568   - { "onesuperior", XK_onesuperior },
569   - { "masculine", XK_masculine },
570   - { "guillemotright", XK_guillemotright },
571   - { "onequarter", XK_onequarter },
572   - { "onehalf", XK_onehalf },
573   - { "threequarters", XK_threequarters },
574   - { "questiondown", XK_questiondown },
575   - { "Agrave", XK_Agrave },
576   - { "Aacute", XK_Aacute },
577   - { "Acircumflex", XK_Acircumflex },
578   - { "Atilde", XK_Atilde },
579   - { "Adiaeresis", XK_Adiaeresis },
580   - { "Aring", XK_Aring },
581   - { "AE", XK_AE },
582   - { "Ccedilla", XK_Ccedilla },
583   - { "Egrave", XK_Egrave },
584   - { "Eacute", XK_Eacute },
585   - { "Ecircumflex", XK_Ecircumflex },
586   - { "Ediaeresis", XK_Ediaeresis },
587   - { "Igrave", XK_Igrave },
588   - { "Iacute", XK_Iacute },
589   - { "Icircumflex", XK_Icircumflex },
590   - { "Idiaeresis", XK_Idiaeresis },
591   - { "ETH", XK_ETH },
592   - { "Eth", XK_Eth },
593   - { "Ntilde", XK_Ntilde },
594   - { "Ograve", XK_Ograve },
595   - { "Oacute", XK_Oacute },
596   - { "Ocircumflex", XK_Ocircumflex },
597   - { "Otilde", XK_Otilde },
598   - { "Odiaeresis", XK_Odiaeresis },
599   - { "multiply", XK_multiply },
600   - { "Ooblique", XK_Ooblique },
601   - { "Ugrave", XK_Ugrave },
602   - { "Uacute", XK_Uacute },
603   - { "Ucircumflex", XK_Ucircumflex },
604   - { "Udiaeresis", XK_Udiaeresis },
605   - { "Yacute", XK_Yacute },
606   - { "THORN", XK_THORN },
607   - { "Thorn", XK_Thorn },
608   - { "ssharp", XK_ssharp },
609   - { "agrave", XK_agrave },
610   - { "aacute", XK_aacute },
611   - { "acircumflex", XK_acircumflex },
612   - { "atilde", XK_atilde },
613   - { "adiaeresis", XK_adiaeresis },
614   - { "aring", XK_aring },
615   - { "ae", XK_ae },
616   - { "ccedilla", XK_ccedilla },
617   - { "egrave", XK_egrave },
618   - { "eacute", XK_eacute },
619   - { "ecircumflex", XK_ecircumflex },
620   - { "ediaeresis", XK_ediaeresis },
621   - { "igrave", XK_igrave },
622   - { "iacute", XK_iacute },
623   - { "icircumflex", XK_icircumflex },
624   - { "idiaeresis", XK_idiaeresis },
625   - { "eth", XK_eth },
626   - { "ntilde", XK_ntilde },
627   - { "ograve", XK_ograve },
628   - { "oacute", XK_oacute },
629   - { "ocircumflex", XK_ocircumflex },
630   - { "otilde", XK_otilde },
631   - { "odiaeresis", XK_odiaeresis },
632   - { "division", XK_division },
633   - { "oslash", XK_oslash },
634   - { "ugrave", XK_ugrave },
635   - { "uacute", XK_uacute },
636   - { "ucircumflex", XK_ucircumflex },
637   - { "udiaeresis", XK_udiaeresis },
638   - { "yacute", XK_yacute },
639   - { "thorn", XK_thorn },
640   - { "ydiaeresis", XK_ydiaeresis },
641   -
642   - // The following are, umm, hacks to allow symbolic names for
643   - // control codes.
644   - #if !defined(_WIN32)
645   - { "BackSpace", 0x08 },
646   - { "Tab", 0x09 },
647   - { "Linefeed", 0x0a },
648   - { "Return", 0x0d },
649   - { "Escape", 0x1b },
650   - { "Delete", 0x7f },
651   - #endif
652   - };
653   -
654   - size_t ix;
655   -
656   - if(strncasecmp(id,"0x",2) == 0) {
657   -
658   - unsigned int rc = 0;
659   -
660   - if(sscanf(id + 2, "%x", &rc) != 1)
661   - {
662   - errno = EINVAL;
663   - return 0;
664   - }
665   -
666   - return (unsigned short) rc;
667   -
668   - }
669   -
670   - for(ix=0;ix < (sizeof(latin)/sizeof(latin[0])); ix++) {
671   - if(!strcasecmp(id,latin[ix].name))
672   - return latin[ix].keysym;
673   - }
674   -
675   - if(strlen(id) != 1)
676   - {
677   - errno = EINVAL;
678   - return 0;
679   - }
680   -
681   - return (unsigned short) *id;
682   -
683   -}
684   -
685   -
src/core/charset/charset.c 0 → 100644
... ... @@ -0,0 +1,271 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como charset.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +/**
  33 + * @file charset.c
  34 + *
  35 + * @brief This module handles character sets.
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +#include <X11keysym.h>
  40 +#include <lib3270/charset.h>
  41 +#include <lib3270/log.h>
  42 +#include <lib3270/trace.h>
  43 +
  44 +/*
  45 + * EBCDIC-to-Unicode translation tables.
  46 + * Each table maps EBCDIC codes X'41' through X'FE' to UCS-2.
  47 + * Other codes are mapped programmatically.
  48 + */
  49 +#define UT_SIZE 190
  50 +#define UT_OFFSET 0x41
  51 +
  52 +/*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/
  53 +
  54 +const unsigned short ebc2asc0[256] =
  55 +{
  56 + /*00*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  57 + /*08*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  58 + /*10*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  59 + /*18*/ 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x3b, 0x20,
  60 + /*20*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  61 + /*28*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  62 + /*30*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  63 + /*38*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  64 + /*40*/ 0x20, 0x20, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
  65 + /*48*/ 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c,
  66 + /*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
  67 + /*58*/ 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0xac,
  68 + /*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
  69 + /*68*/ 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f,
  70 + /*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
  71 + /*78*/ 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22,
  72 + /*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
  73 + /*88*/ 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1,
  74 + /*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
  75 + /*98*/ 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4,
  76 + /*a0*/ 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
  77 + /*a8*/ 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae,
  78 + /*b0*/ 0x5e, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
  79 + /*b8*/ 0xbd, 0xbe, 0x5b, 0x5d, 0xaf, 0xa8, 0xb4, 0xd7,
  80 + /*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
  81 + /*c8*/ 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
  82 + /*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
  83 + /*d8*/ 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff,
  84 + /*e0*/ 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
  85 + /*e8*/ 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
  86 + /*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
  87 + /*f8*/ 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x20
  88 +};
  89 +
  90 +static const unsigned short asc2ebc0[256] =
  91 +{
  92 + /*00*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  93 + /*08*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  94 + /*10*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  95 + /*18*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  96 + /*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
  97 + /*28*/ 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
  98 + /*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
  99 + /*38*/ 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
  100 + /*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
  101 + /*48*/ 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
  102 + /*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
  103 + /*58*/ 0xe7, 0xe8, 0xe9, 0xba, 0xe0, 0xbb, 0xb0, 0x6d,
  104 + /*60*/ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  105 + /*68*/ 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
  106 + /*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
  107 + /*78*/ 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x00,
  108 + /*80*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  109 + /*88*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  110 + /*90*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  111 + /*98*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  112 + /*a0*/ 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5,
  113 + /*a8*/ 0xbd, 0xb4, 0x9a, 0x8a, 0x5f, 0xca, 0xaf, 0xbc,
  114 + /*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
  115 + /*b8*/ 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,
  116 + /*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
  117 + /*c8*/ 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
  118 + /*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
  119 + /*d8*/ 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xad, 0xae, 0x59,
  120 + /*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
  121 + /*e8*/ 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
  122 + /*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
  123 + /*f8*/ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf
  124 +};
  125 +
  126 +static const unsigned short asc2uc[UT_SIZE] =
  127 +{
  128 + /*40*/ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
  129 + /*48*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  130 + /*50*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
  131 + /*58*/ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
  132 + /*60*/ 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
  133 + /*68*/ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  134 + /*70*/ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
  135 + /*78*/ 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
  136 + /*80*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
  137 + /*88*/ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
  138 + /*90*/ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
  139 + /*98*/ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
  140 + /*a0*/ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
  141 + /*a8*/ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
  142 + /*b0*/ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
  143 + /*b8*/ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
  144 + /*c0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
  145 + /*c8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
  146 + /*d0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
  147 + /*d8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
  148 + /*e0*/ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
  149 + /*e8*/ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
  150 + /*f0*/ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xf7,
  151 + /*f8*/ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde
  152 +};
  153 +
  154 +typedef struct _info
  155 +{
  156 + const char * name;
  157 + unsigned long cgcsgid;
  158 + const unsigned short * chr;
  159 +} remap;
  160 +
  161 +static const remap charset[] =
  162 +{
  163 + {
  164 + "us",
  165 + LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET,
  166 + (const unsigned short [])
  167 + {
  168 + 0x0000, 0x0000
  169 + }
  170 + },
  171 +
  172 + {
  173 + "bracket",
  174 + LIB3270_DEFAULT_CGEN|LIB3270_DEFAULT_CSET,
  175 + (const unsigned short [])
  176 + {
  177 + 0x00ad, '[',
  178 + 0x00ba, XK_Yacute,
  179 + 0x00bd, ']',
  180 + 0x00bb, XK_diaeresis,
  181 + 0x0000, 0x0000
  182 + }
  183 + },
  184 +
  185 + {
  186 + "cp500",
  187 + LIB3270_DEFAULT_CGEN|0x000001F4,
  188 + (const unsigned short [])
  189 + {
  190 + 0x004a, '[',
  191 + 0x004f, '!',
  192 + 0x005a, ']',
  193 + 0x005f, '^',
  194 + 0x00b0, XK_percent,
  195 + 0x00ba, XK_notsign,
  196 + 0x00bb, XK_bar
  197 + }
  198 + },
  199 +
  200 + // Terminate list
  201 + {
  202 + NULL
  203 + }
  204 +
  205 +};
  206 +
  207 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  208 +
  209 +static void copy_charset(const unsigned short *from, unsigned short *to)
  210 +{
  211 + int f;
  212 + for(f=0;f < UT_SIZE;f++)
  213 + to[f+UT_OFFSET] = from[f];
  214 +}
  215 +
  216 +LIB3270_EXPORT void lib3270_reset_charset(H3270 *hSession, const char * host, const char * display, unsigned long cgcsgid)
  217 +{
  218 + int f;
  219 +
  220 + #define replace_pointer(x,v) if(x) { lib3270_free(x); }; x = strdup(v)
  221 +
  222 + replace_pointer(hSession->charset.host, host);
  223 + replace_pointer(hSession->charset.display,display);
  224 +
  225 + hSession->charset.cgcsgid = cgcsgid;
  226 +
  227 + memcpy(hSession->charset.ebc2asc, ebc2asc0, sizeof(hSession->charset.ebc2asc));
  228 + memcpy(hSession->charset.asc2ebc, asc2ebc0, sizeof(hSession->charset.asc2ebc));
  229 +
  230 + for(f=0;f<UT_OFFSET;f++)
  231 + hSession->charset.asc2uc[f] = f;
  232 +
  233 + copy_charset(asc2uc,hSession->charset.asc2uc);
  234 +
  235 +}
  236 +
  237 +LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name)
  238 +{
  239 + int f;
  240 +
  241 + if(!name)
  242 + {
  243 + lib3270_reset_charset(hSession,"us","ISO-8859-1", LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET);
  244 + return 0;
  245 + }
  246 +
  247 + if(hSession->charset.host && !strcasecmp(name,hSession->charset.host))
  248 + return 0;
  249 +
  250 + for(f=0;charset[f].name != NULL;f++)
  251 + {
  252 + if(!strcasecmp(name,charset[f].name))
  253 + {
  254 + // Found required charset
  255 + int c;
  256 +
  257 + debug("%s: %s -> %s",__FUNCTION__,hSession->charset.host,charset[f].name);
  258 +
  259 + lib3270_reset_charset(hSession,charset[f].name,"ISO-8859-1", charset[f].cgcsgid);
  260 +
  261 + for(c=0;charset[f].chr[c];c+=2)
  262 + lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0);
  263 +
  264 + return 0;
  265 + }
  266 + }
  267 +
  268 + return ENOENT;
  269 +
  270 +}
  271 +
... ...
src/core/charset/convert.c 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como charset.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +/**
  33 + * @file charset/convert.c
  34 + *
  35 + * @brief This module handles ebc<->asc conversion.
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +#include <lib3270/charset.h>
  40 +#include <lib3270/log.h>
  41 +#include <lib3270/trace.h>
  42 +
  43 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  44 +
  45 +LIB3270_EXPORT const char * lib3270_asc2ebc(H3270 *hSession, unsigned char *buffer, int sz)
  46 +{
  47 + int f;
  48 + if(sz < 0)
  49 + sz = strlen((const char *) buffer);
  50 +
  51 + if(sz > 0)
  52 + {
  53 + for(f=0;f<sz;f++)
  54 + buffer[f] = hSession->charset.asc2ebc[buffer[f]];
  55 + }
  56 +
  57 + return (const char *) buffer;
  58 +}
  59 +
  60 +LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buffer, int sz)
  61 +{
  62 + int f;
  63 + if(sz < 0)
  64 + sz = strlen((const char *) buffer);
  65 +
  66 + if(sz > 0)
  67 + {
  68 + for(f=0;f<sz;f++)
  69 + buffer[f] = hSession->charset.ebc2asc[buffer[f]];
  70 + }
  71 +
  72 + return (const char *) buffer;
  73 +}
  74 +
... ...
src/core/charset/getset.c 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como charset.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +/**
  33 + * @file charset/getset.c
  34 + *
  35 + * @brief This module handles get/set the terminal character set.
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +#include <X11keysym.h>
  40 +#include <lib3270/charset.h>
  41 +#include <lib3270/log.h>
  42 +#include <lib3270/trace.h>
  43 +
  44 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  45 +
  46 +LIB3270_EXPORT const char * lib3270_get_default_charset(void)
  47 +{
  48 + return "ISO-8859-1";
  49 +}
  50 +
  51 +LIB3270_EXPORT const char * lib3270_get_display_charset(const H3270 *hSession)
  52 +{
  53 + return hSession->charset.display ? hSession->charset.display : "ISO-8859-1";
  54 +}
  55 +
  56 +LIB3270_EXPORT const char * lib3270_get_host_charset(const H3270 *hSession)
  57 +{
  58 + return hSession->charset.host;
  59 +}
  60 +
... ...
src/core/charset/remap.c 0 → 100644
... ... @@ -0,0 +1,326 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como charset.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +/**
  33 + * @file charset/remap.c
  34 + *
  35 + * @brief
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +#include <lib3270/charset.h>
  40 +#include <lib3270/log.h>
  41 +#include <lib3270/trace.h>
  42 +#include <X11keysym.h>
  43 +
  44 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  45 +
  46 +///
  47 +/// @brief Process a single character definition.
  48 +///
  49 +LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way)
  50 +{
  51 + // unsigned char cg;
  52 + CHECK_SESSION_HANDLE(hSession);
  53 +
  54 + // Ignore mappings of EBCDIC control codes and the space character.
  55 + if (ebc <= 0x40)
  56 + return;
  57 +
  58 + // If they want to map to a NULL or a blank, make it a one-way blank.
  59 + if (iso == 0x0)
  60 + iso = 0x20;
  61 + if (iso == 0x20)
  62 + one_way = True;
  63 +
  64 + if (iso <= 0xff)
  65 + {
  66 + if (scope == BOTH || scope == CS_ONLY)
  67 + {
  68 + if (ebc > 0x40)
  69 + {
  70 + hSession->charset.ebc2asc[ebc] = iso;
  71 + if (!one_way)
  72 + hSession->charset.asc2ebc[iso] = ebc;
  73 + }
  74 + }
  75 +
  76 + }
  77 +}
  78 +
  79 +LIB3270_EXPORT unsigned short lib3270_translate_char(const char *id)
  80 +{
  81 +
  82 + static const struct
  83 + {
  84 + const char * name;
  85 + unsigned short keysym;
  86 + }
  87 + latin[] =
  88 + {
  89 + { "space", XK_space },
  90 + { "exclam", XK_exclam },
  91 + { "quotedbl", XK_quotedbl },
  92 + { "numbersign", XK_numbersign },
  93 + { "dollar", XK_dollar },
  94 + { "percent", XK_percent },
  95 + { "ampersand", XK_ampersand },
  96 + { "apostrophe", XK_apostrophe },
  97 + { "quoteright", XK_quoteright },
  98 + { "parenleft", XK_parenleft },
  99 + { "parenright", XK_parenright },
  100 + { "asterisk", XK_asterisk },
  101 + { "plus", XK_plus },
  102 + { "comma", XK_comma },
  103 + { "minus", XK_minus },
  104 + { "period", XK_period },
  105 + { "slash", XK_slash },
  106 + { "0", XK_0 },
  107 + { "1", XK_1 },
  108 + { "2", XK_2 },
  109 + { "3", XK_3 },
  110 + { "4", XK_4 },
  111 + { "5", XK_5 },
  112 + { "6", XK_6 },
  113 + { "7", XK_7 },
  114 + { "8", XK_8 },
  115 + { "9", XK_9 },
  116 + { "colon", XK_colon },
  117 + { "semicolon", XK_semicolon },
  118 + { "less", XK_less },
  119 + { "equal", XK_equal },
  120 + { "greater", XK_greater },
  121 + { "question", XK_question },
  122 + { "at", XK_at },
  123 + { "A", XK_A },
  124 + { "B", XK_B },
  125 + { "C", XK_C },
  126 + { "D", XK_D },
  127 + { "E", XK_E },
  128 + { "F", XK_F },
  129 + { "G", XK_G },
  130 + { "H", XK_H },
  131 + { "I", XK_I },
  132 + { "J", XK_J },
  133 + { "K", XK_K },
  134 + { "L", XK_L },
  135 + { "M", XK_M },
  136 + { "N", XK_N },
  137 + { "O", XK_O },
  138 + { "P", XK_P },
  139 + { "Q", XK_Q },
  140 + { "R", XK_R },
  141 + { "S", XK_S },
  142 + { "T", XK_T },
  143 + { "U", XK_U },
  144 + { "V", XK_V },
  145 + { "W", XK_W },
  146 + { "X", XK_X },
  147 + { "Y", XK_Y },
  148 + { "Z", XK_Z },
  149 + { "bracketleft", XK_bracketleft },
  150 + { "backslash", XK_backslash },
  151 + { "bracketright", XK_bracketright },
  152 + { "asciicircum", XK_asciicircum },
  153 + { "underscore", XK_underscore },
  154 + { "grave", XK_grave },
  155 + { "quoteleft", XK_quoteleft },
  156 + { "a", XK_a },
  157 + { "b", XK_b },
  158 + { "c", XK_c },
  159 + { "d", XK_d },
  160 + { "e", XK_e },
  161 + { "f", XK_f },
  162 + { "g", XK_g },
  163 + { "h", XK_h },
  164 + { "i", XK_i },
  165 + { "j", XK_j },
  166 + { "k", XK_k },
  167 + { "l", XK_l },
  168 + { "m", XK_m },
  169 + { "n", XK_n },
  170 + { "o", XK_o },
  171 + { "p", XK_p },
  172 + { "q", XK_q },
  173 + { "r", XK_r },
  174 + { "s", XK_s },
  175 + { "t", XK_t },
  176 + { "u", XK_u },
  177 + { "v", XK_v },
  178 + { "w", XK_w },
  179 + { "x", XK_x },
  180 + { "y", XK_y },
  181 + { "z", XK_z },
  182 + { "braceleft", XK_braceleft },
  183 + { "bar", XK_bar },
  184 + { "braceright", XK_braceright },
  185 + { "asciitilde", XK_asciitilde },
  186 + { "nobreakspace", XK_nobreakspace },
  187 + { "exclamdown", XK_exclamdown },
  188 + { "cent", XK_cent },
  189 + { "sterling", XK_sterling },
  190 + { "currency", XK_currency },
  191 + { "yen", XK_yen },
  192 + { "brokenbar", XK_brokenbar },
  193 + { "section", XK_section },
  194 + { "diaeresis", XK_diaeresis },
  195 + { "copyright", XK_copyright },
  196 + { "ordfeminine", XK_ordfeminine },
  197 + { "guillemotleft", XK_guillemotleft },
  198 + { "notsign", XK_notsign },
  199 + { "hyphen", XK_hyphen },
  200 + { "registered", XK_registered },
  201 + { "macron", XK_macron },
  202 + { "degree", XK_degree },
  203 + { "plusminus", XK_plusminus },
  204 + { "twosuperior", XK_twosuperior },
  205 + { "threesuperior", XK_threesuperior },
  206 + { "acute", XK_acute },
  207 + { "mu", XK_mu },
  208 + { "paragraph", XK_paragraph },
  209 + { "periodcentered", XK_periodcentered },
  210 + { "cedilla", XK_cedilla },
  211 + { "onesuperior", XK_onesuperior },
  212 + { "masculine", XK_masculine },
  213 + { "guillemotright", XK_guillemotright },
  214 + { "onequarter", XK_onequarter },
  215 + { "onehalf", XK_onehalf },
  216 + { "threequarters", XK_threequarters },
  217 + { "questiondown", XK_questiondown },
  218 + { "Agrave", XK_Agrave },
  219 + { "Aacute", XK_Aacute },
  220 + { "Acircumflex", XK_Acircumflex },
  221 + { "Atilde", XK_Atilde },
  222 + { "Adiaeresis", XK_Adiaeresis },
  223 + { "Aring", XK_Aring },
  224 + { "AE", XK_AE },
  225 + { "Ccedilla", XK_Ccedilla },
  226 + { "Egrave", XK_Egrave },
  227 + { "Eacute", XK_Eacute },
  228 + { "Ecircumflex", XK_Ecircumflex },
  229 + { "Ediaeresis", XK_Ediaeresis },
  230 + { "Igrave", XK_Igrave },
  231 + { "Iacute", XK_Iacute },
  232 + { "Icircumflex", XK_Icircumflex },
  233 + { "Idiaeresis", XK_Idiaeresis },
  234 + { "ETH", XK_ETH },
  235 + { "Eth", XK_Eth },
  236 + { "Ntilde", XK_Ntilde },
  237 + { "Ograve", XK_Ograve },
  238 + { "Oacute", XK_Oacute },
  239 + { "Ocircumflex", XK_Ocircumflex },
  240 + { "Otilde", XK_Otilde },
  241 + { "Odiaeresis", XK_Odiaeresis },
  242 + { "multiply", XK_multiply },
  243 + { "Ooblique", XK_Ooblique },
  244 + { "Ugrave", XK_Ugrave },
  245 + { "Uacute", XK_Uacute },
  246 + { "Ucircumflex", XK_Ucircumflex },
  247 + { "Udiaeresis", XK_Udiaeresis },
  248 + { "Yacute", XK_Yacute },
  249 + { "THORN", XK_THORN },
  250 + { "Thorn", XK_Thorn },
  251 + { "ssharp", XK_ssharp },
  252 + { "agrave", XK_agrave },
  253 + { "aacute", XK_aacute },
  254 + { "acircumflex", XK_acircumflex },
  255 + { "atilde", XK_atilde },
  256 + { "adiaeresis", XK_adiaeresis },
  257 + { "aring", XK_aring },
  258 + { "ae", XK_ae },
  259 + { "ccedilla", XK_ccedilla },
  260 + { "egrave", XK_egrave },
  261 + { "eacute", XK_eacute },
  262 + { "ecircumflex", XK_ecircumflex },
  263 + { "ediaeresis", XK_ediaeresis },
  264 + { "igrave", XK_igrave },
  265 + { "iacute", XK_iacute },
  266 + { "icircumflex", XK_icircumflex },
  267 + { "idiaeresis", XK_idiaeresis },
  268 + { "eth", XK_eth },
  269 + { "ntilde", XK_ntilde },
  270 + { "ograve", XK_ograve },
  271 + { "oacute", XK_oacute },
  272 + { "ocircumflex", XK_ocircumflex },
  273 + { "otilde", XK_otilde },
  274 + { "odiaeresis", XK_odiaeresis },
  275 + { "division", XK_division },
  276 + { "oslash", XK_oslash },
  277 + { "ugrave", XK_ugrave },
  278 + { "uacute", XK_uacute },
  279 + { "ucircumflex", XK_ucircumflex },
  280 + { "udiaeresis", XK_udiaeresis },
  281 + { "yacute", XK_yacute },
  282 + { "thorn", XK_thorn },
  283 + { "ydiaeresis", XK_ydiaeresis },
  284 +
  285 + // The following are, umm, hacks to allow symbolic names for
  286 + // control codes.
  287 + #if !defined(_WIN32)
  288 + { "BackSpace", 0x08 },
  289 + { "Tab", 0x09 },
  290 + { "Linefeed", 0x0a },
  291 + { "Return", 0x0d },
  292 + { "Escape", 0x1b },
  293 + { "Delete", 0x7f },
  294 + #endif
  295 + };
  296 +
  297 + size_t ix;
  298 +
  299 + if(strncasecmp(id,"0x",2) == 0) {
  300 +
  301 + unsigned int rc = 0;
  302 +
  303 + if(sscanf(id + 2, "%x", &rc) != 1)
  304 + {
  305 + errno = EINVAL;
  306 + return 0;
  307 + }
  308 +
  309 + return (unsigned short) rc;
  310 +
  311 + }
  312 +
  313 + for(ix=0;ix < (sizeof(latin)/sizeof(latin[0])); ix++) {
  314 + if(!strcasecmp(id,latin[ix].name))
  315 + return latin[ix].keysym;
  316 + }
  317 +
  318 + if(strlen(id) != 1)
  319 + {
  320 + errno = EINVAL;
  321 + return 0;
  322 + }
  323 +
  324 + return (unsigned short) *id;
  325 +
  326 +}
... ...
src/core/charset/utf8.c 0 → 100644
... ... @@ -0,0 +1,359 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como utf8.c e possui 514 linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
  30 + *
  31 + */
  32 +
  33 +/**
  34 + * @file utf8.c
  35 + * @brief 3270 Terminal Emulator UTF-8 conversions
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +// #include "api.h"
  40 +
  41 +#include "popupsc.h"
  42 +#include "utf8c.h"
  43 +
  44 +// char *locale_codeset = CN;
  45 +
  46 +// static int utf8_ix = -1;
  47 +
  48 +// static Boolean is_utf8 = False;
  49 +#if defined(X3270_DBCS) /*[*/
  50 +static Boolean is_gb18030 = False;
  51 +#endif /*]*/
  52 +
  53 +/* Various types of 8-bit character sets we understand. */
  54 +enum UTF_IX {
  55 + /* Real translations from 8-bit encodings to UTF-8. */
  56 + U_ISO8859_1,
  57 + U_ISO8859_2,
  58 + U_ISO8859_7,
  59 + U_ISO8859_8,
  60 + U_ISO8859_9,
  61 + U_ISO8859_11,
  62 + U_ISO8859_15,
  63 + U_KOI8_R,
  64 +
  65 +#if defined(X3270_DBCS) /*[*/
  66 + /* Multi-byte expansions of non-UTF-8 encodings. */
  67 + PSEUDO_GB18030,
  68 +#endif /*]*/
  69 +
  70 + U_MAX
  71 +};
  72 +
  73 +/*
  74 + * Names of the above (real) character sets. These are the names used in
  75 + * displayCharset resources.
  76 + */ /*
  77 +static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[]
  78 + "iso8859-1",
  79 + "iso8859-2",
  80 + "iso8859-7",
  81 + "iso8859-8",
  82 + "iso8859-9",
  83 + "iso8859-11",
  84 + "iso8859-15",
  85 + "koi8-r",
  86 + CN
  87 +};
  88 +*/
  89 +
  90 +/*
  91 + * UTF-8 translation tables.
  92 + * These are used to convert code points 0xa0 through 0xff to UTF-8.
  93 + *
  94 + * Note that this could be done much more generally with the iconv library
  95 + * or the ICU library, but there is no guarantee that either is available or
  96 + * properly configured.
  97 + */ /*
  98 +#define HI_SIZE 96
  99 +static char *utf8_tab[U_MAX][96] = {
  100 +
  101 + // iso8859-1
  102 + {
  103 + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
  104 + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
  105 + "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
  106 + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
  107 + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
  108 + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
  109 + "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
  110 + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf",
  111 + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
  112 + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
  113 + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
  114 + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
  115 + "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93",
  116 + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
  117 + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
  118 + "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f",
  119 + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
  120 + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
  121 + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
  122 + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
  123 + "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
  124 + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
  125 + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
  126 + "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf"
  127 +},
  128 +// iso8859-2
  129 +{
  130 + "\xc2\xa0", "\xc4\x84", "\xcb\x98", "\xc5\x81",
  131 + "\xc2\xa4", "\xc4\xbd", "\xc5\x9a", "\xc2\xa7",
  132 + "\xc2\xa8", "\xc5\xa0", "\xc5\x9e", "\xc5\xa4",
  133 + "\xc5\xb9", "\xc2\xad", "\xc5\xbd", "\xc5\xbb",
  134 + "\xc2\xb0", "\xc4\x85", "\xcb\x9b", "\xc5\x82",
  135 + "\xc2\xb4", "\xc4\xbe", "\xc5\x9b", "\xcb\x87",
  136 + "\xc2\xb8", "\xc5\xa1", "\xc5\x9f", "\xc5\xa5",
  137 + "\xc5\xba", "\xcb\x9d", "\xc5\xbe", "\xc5\xbc",
  138 + "\xc5\x94", "\xc3\x81", "\xc3\x82", "\xc4\x82",
  139 + "\xc3\x84", "\xc4\xb9", "\xc4\x86", "\xc3\x87",
  140 + "\xc4\x8c", "\xc3\x89", "\xc4\x98", "\xc3\x8b",
  141 + "\xc4\x9a", "\xc3\x8d", "\xc3\x8e", "\xc4\x8e",
  142 + "\xc4\x90", "\xc5\x83", "\xc5\x87", "\xc3\x93",
  143 + "\xc3\x94", "\xc5\x90", "\xc3\x96", "\xc3\x97",
  144 + "\xc5\x98", "\xc5\xae", "\xc3\x9a", "\xc5\xb0",
  145 + "\xc3\x9c", "\xc3\x9d", "\xc5\xa2", "\xc3\x9f",
  146 + "\xc5\x95", "\xc3\xa1", "\xc3\xa2", "\xc4\x83",
  147 + "\xc3\xa4", "\xc4\xba", "\xc4\x87", "\xc3\xa7",
  148 + "\xc4\x8d", "\xc3\xa9", "\xc4\x99", "\xc3\xab",
  149 + "\xc4\x9b", "\xc3\xad", "\xc3\xae", "\xc4\x8f",
  150 + "\xc4\x91", "\xc5\x84", "\xc5\x88", "\xc3\xb3",
  151 + "\xc3\xb4", "\xc5\x91", "\xc3\xb6", "\xc3\xb7",
  152 + "\xc5\x99", "\xc5\xaf", "\xc3\xba", "\xc5\xb1",
  153 + "\xc3\xbc", "\xc3\xbd", "\xc5\xa3", "\xcb\x99"
  154 +},
  155 +// iso8859-7
  156 +{
  157 + "\xc2\xa0", "\xe2\x80\x98", "\xe2\x80\x99", "\xc2\xa3",
  158 + "\xe2\x82\xac", "\xe2\x82\xaf", "\xc2\xa6", "\xc2\xa7",
  159 + "\xc2\xa8", "\xc2\xa9", "\xcd\xba", "\xc2\xab",
  160 + "\xc2\xac", "\xc2\xad", " ", "\xe2\x80\x95",
  161 + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
  162 + "\xce\x84", "\xce\x85", "\xce\x86", "\xc2\xb7",
  163 + "\xce\x88", "\xce\x89", "\xce\x8a", "\xc2\xbb",
  164 + "\xce\x8c", "\xc2\xbd", "\xce\x8e", "\xce\x8f",
  165 + "\xce\x90", "\xce\x91", "\xce\x92", "\xce\x93",
  166 + "\xce\x94", "\xce\x95", "\xce\x96", "\xce\x97",
  167 + "\xce\x98", "\xce\x99", "\xce\x9a", "\xce\x9b",
  168 + "\xce\x9c", "\xce\x9d", "\xce\x9e", "\xce\x9f",
  169 + "\xce\xa0", "\xce\xa1", " ", "\xce\xa3",
  170 + "\xce\xa4", "\xce\xa5", "\xce\xa6", "\xce\xa7",
  171 + "\xce\xa8", "\xce\xa9", "\xce\xaa", "\xce\xab",
  172 + "\xce\xac", "\xce\xad", "\xce\xae", "\xce\xaf",
  173 + "\xce\xb0", "\xce\xb1", "\xce\xb2", "\xce\xb3",
  174 + "\xce\xb4", "\xce\xb5", "\xce\xb6", "\xce\xb7",
  175 + "\xce\xb8", "\xce\xb9", "\xce\xba", "\xce\xbb",
  176 + "\xce\xbc", "\xce\xbd", "\xce\xbe", "\xce\xbf",
  177 + "\xcf\x80", "\xcf\x81", "\xcf\x82", "\xcf\x83",
  178 + "\xcf\x84", "\xcf\x85", "\xcf\x86", "\xcf\x87",
  179 + "\xcf\x88", "\xcf\x89", "\xcf\x8a", "\xcf\x8b",
  180 + "\xcf\x8c", "\xcf\x8d", "\xcf\x8e", " "
  181 +},
  182 +// iso8859-8
  183 +{
  184 + "\xc2\xa0", " ", "\xc2\xa2", "\xc2\xa3",
  185 + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
  186 + "\xc2\xa8", "\xc2\xa9", "\xc3\x97", "\xc2\xab",
  187 + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
  188 + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
  189 + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
  190 + "\xc2\xb8", "\xc2\xb9", "\xc3\xb7", "\xc2\xbb",
  191 + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", " ",
  192 + " ", " ", " ", " ",
  193 + " ", " ", " ", " ",
  194 + " ", " ", " ", " ",
  195 + " ", " ", " ", " ",
  196 + " ", " ", " ", " ",
  197 + " ", " ", " ", " ",
  198 + " ", " ", " ", " ",
  199 + " ", " ", " ", "\xe2\x80\x97",
  200 + "\xd7\x90", "\xd7\x91", "\xd7\x92", "\xd7\x93",
  201 + "\xd7\x94", "\xd7\x95", "\xd7\x96", "\xd7\x97",
  202 + "\xd7\x98", "\xd7\x99", "\xd7\x9a", "\xd7\x9b",
  203 + "\xd7\x9c", "\xd7\x9d", "\xd7\x9e", "\xd7\x9f",
  204 + "\xd7\xa0", "\xd7\xa1", "\xd7\xa2", "\xd7\xa3",
  205 + "\xd7\xa4", "\xd7\xa5", "\xd7\xa6", "\xd7\xa7",
  206 + "\xd7\xa8", "\xd7\xa9", "\xd7\xaa", " ",
  207 + " ", "\xe2\x80\x8e", "\xe2\x80\x8f", " "
  208 +},
  209 +// iso8859-9
  210 +{
  211 + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
  212 + "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
  213 + "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
  214 + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
  215 + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
  216 + "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
  217 + "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
  218 + "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf",
  219 + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
  220 + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
  221 + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
  222 + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
  223 + "\xc4\x9e", "\xc3\x91", "\xc3\x92", "\xc3\x93",
  224 + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
  225 + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
  226 + "\xc3\x9c", "\xc4\xb0", "\xc5\x9e", "\xc3\x9f",
  227 + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
  228 + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
  229 + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
  230 + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
  231 + "\xc4\x9f", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
  232 + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
  233 + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
  234 + "\xc3\xbc", "\xc4\xb1", "\xc5\x9f", "\xc3\xbf"
  235 +},
  236 +// iso8859-11
  237 +{
  238 + "\xc2\xa0", "\xe0\xb8\x81", "\xe0\xb8\x82", "\xe0\xb8\x83",
  239 + "\xe0\xb8\x84", "\xe0\xb8\x85", "\xe0\xb8\x86", "\xe0\xb8\x87",
  240 + "\xe0\xb8\x88", "\xe0\xb8\x89", "\xe0\xb8\x8a", "\xe0\xb8\x8b",
  241 + "\xe0\xb8\x8c", "\xe0\xb8\x8d", "\xe0\xb8\x8e", "\xe0\xb8\x8f",
  242 + "\xe0\xb8\x90", "\xe0\xb8\x91", "\xe0\xb8\x92", "\xe0\xb8\x93",
  243 + "\xe0\xb8\x94", "\xe0\xb8\x95", "\xe0\xb8\x96", "\xe0\xb8\x97",
  244 + "\xe0\xb8\x98", "\xe0\xb8\x99", "\xe0\xb8\x9a", "\xe0\xb8\x9b",
  245 + "\xe0\xb8\x9c", "\xe0\xb8\x9d", "\xe0\xb8\x9e", "\xe0\xb8\x9f",
  246 + "\xe0\xb8\xa0", "\xe0\xb8\xa1", "\xe0\xb8\xa2", "\xe0\xb8\xa3",
  247 + "\xe0\xb8\xa4", "\xe0\xb8\xa5", "\xe0\xb8\xa6", "\xe0\xb8\xa7",
  248 + "\xe0\xb8\xa8", "\xe0\xb8\xa9", "\xe0\xb8\xaa", "\xe0\xb8\xab",
  249 + "\xe0\xb8\xac", "\xe0\xb8\xad", "\xe0\xb8\xae", "\xe0\xb8\xaf",
  250 + "\xe0\xb8\xb0", "\xe0\xb8\xb1", "\xe0\xb8\xb2", "\xe0\xb8\xb3",
  251 + "\xe0\xb8\xb4", "\xe0\xb8\xb5", "\xe0\xb8\xb6", "\xe0\xb8\xb7",
  252 + "\xe0\xb8\xb8", "\xe0\xb8\xb9", "\xe0\xb8\xba", " ",
  253 + " ", " ", " ", "\xe0\xb8\xbf",
  254 + "\xe0\xb9\x80", "\xe0\xb9\x81", "\xe0\xb9\x82", "\xe0\xb9\x83",
  255 + "\xe0\xb9\x84", "\xe0\xb9\x85", "\xe0\xb9\x86", "\xe0\xb9\x87",
  256 + "\xe0\xb9\x88", "\xe0\xb9\x89", "\xe0\xb9\x8a", "\xe0\xb9\x8b",
  257 + "\xe0\xb9\x8c", "\xe0\xb9\x8d", "\xe0\xb9\x8e", "\xe0\xb9\x8f",
  258 + "\xe0\xb9\x90", "\xe0\xb9\x91", "\xe0\xb9\x92", "\xe0\xb9\x93",
  259 + "\xe0\xb9\x94", "\xe0\xb9\x95", "\xe0\xb9\x96", "\xe0\xb9\x97",
  260 + "\xe0\xb9\x98", "\xe0\xb9\x99", "\xe0\xb9\x9a", "\xe0\xb9\x9b",
  261 + " ", " ", " ", " "
  262 +},
  263 +// iso8859-15
  264 +{
  265 + "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
  266 + "\xe2\x82\xac", "\xc2\xa5", "\xc5\xa0", "\xc2\xa7",
  267 + "\xc5\xa1", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
  268 + "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
  269 + "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
  270 + "\xc5\xbd", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
  271 + "\xc5\xbe", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
  272 + "\xc5\x92", "\xc5\x93", "\xc5\xb8", "\xc2\xbf",
  273 + "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
  274 + "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
  275 + "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
  276 + "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
  277 + "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93",
  278 + "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
  279 + "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
  280 + "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f",
  281 + "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
  282 + "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
  283 + "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
  284 + "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
  285 + "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
  286 + "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
  287 + "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
  288 + "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf"
  289 +},
  290 +// koi8-r
  291 +{
  292 + "\xe2\x95\x90", "\xe2\x95\x91", "\xe2\x95\x92", "\xd1\x91",
  293 + "\xe2\x95\x93", "\xe2\x95\x94", "\xe2\x95\x95", "\xe2\x95\x96",
  294 + "\xe2\x95\x97", "\xe2\x95\x98", "\xe2\x95\x99", "\xe2\x95\x9a",
  295 + "\xe2\x95\x9b", "\xe2\x95\x9c", "\xe2\x95\x9d", "\xe2\x95\x9e",
  296 + "\xe2\x95\x9f", "\xe2\x95\xa0", "\xe2\x95\xa1", "\xd0\x81",
  297 + "\xe2\x95\xa2", "\xe2\x95\xa3", "\xe2\x95\xa4", "\xe2\x95\xa5",
  298 + "\xe2\x95\xa6", "\xe2\x95\xa7", "\xe2\x95\xa8", "\xe2\x95\xa9",
  299 + "\xe2\x95\xaa", "\xe2\x95\xab", "\xe2\x95\xac", "\xc2\xa9",
  300 + "\xd1\x8e", "\xd0\xb0", "\xd0\xb1", "\xd1\x86",
  301 + "\xd0\xb4", "\xd0\xb5", "\xd1\x84", "\xd0\xb3",
  302 + "\xd1\x85", "\xd0\xb8", "\xd0\xb9", "\xd0\xba",
  303 + "\xd0\xbb", "\xd0\xbc", "\xd0\xbd", "\xd0\xbe",
  304 + "\xd0\xbf", "\xd1\x8f", "\xd1\x80", "\xd1\x81",
  305 + "\xd1\x82", "\xd1\x83", "\xd0\xb6", "\xd0\xb2",
  306 + "\xd1\x8c", "\xd1\x8b", "\xd0\xb7", "\xd1\x88",
  307 + "\xd1\x8d", "\xd1\x89", "\xd1\x87", "\xd1\x8a",
  308 + "\xd0\xae", "\xd0\x90", "\xd0\x91", "\xd0\xa6",
  309 + "\xd0\x94", "\xd0\x95", "\xd0\xa4", "\xd0\x93",
  310 + "\xd0\xa5", "\xd0\x98", "\xd0\x99", "\xd0\x9a",
  311 + "\xd0\x9b", "\xd0\x9c", "\xd0\x9d", "\xd0\x9e",
  312 + "\xd0\x9f", "\xd0\xaf", "\xd0\xa0", "\xd0\xa1",
  313 + "\xd0\xa2", "\xd0\xa3", "\xd0\x96", "\xd0\x92",
  314 + "\xd0\xac", "\xd0\xab", "\xd0\x97", "\xd0\xa8",
  315 + "\xd0\xad", "\xd0\xa9", "\xd0\xa7", "\xd0\xaa"
  316 +},
  317 +#if defined(X3270_DBCS)
  318 +// pseudo-gb18030 - not actually a UTF-8 expansion
  319 +{
  320 + "\x81\x30\x84\x32", "\x81\x30\x84\x33", "\x81\x30\x84\x34", "\x81\x30\x84\x35",
  321 + "\xa1\xe8", "\x81\x30\x84\x36", "\x81\x30\x84\x37", "\xa1\xec",
  322 + "\xa1\xa7", "\x81\x30\x84\x38", "\x81\x30\x84\x39", "\x81\x30\x85\x30",
  323 + "\x81\x30\x85\x31", "\x81\x30\x85\x32", "\x81\x30\x85\x33", "\x81\x30\x85\x34",
  324 + "\xa1\xe3", "\xa1\xc0", "\x81\x30\x85\x35", "\x81\x30\x85\x36",
  325 + "\x81\x30\x85\x37", "\x81\x30\x85\x38", "\x81\x30\x85\x39", "\xa1\xa4",
  326 + "\x81\x30\x86\x30", "\x81\x30\x86\x31", "\x81\x30\x86\x32", "\x81\x30\x86\x33",
  327 + "\x81\x30\x86\x34", "\x81\x30\x86\x35", "\x81\x30\x86\x36", "\x81\x30\x86\x37",
  328 + "\x81\x30\x86\x38", "\x81\x30\x86\x39", "\x81\x30\x87\x30", "\x81\x30\x87\x31",
  329 + "\x81\x30\x87\x32", "\x81\x30\x87\x33", "\x81\x30\x87\x34", "\x81\x30\x87\x35",
  330 + "\x81\x30\x87\x36", "\x81\x30\x87\x37", "\x81\x30\x87\x38", "\x81\x30\x87\x39",
  331 + "\x81\x30\x88\x30", "\x81\x30\x88\x31", "\x81\x30\x88\x32", "\x81\x30\x88\x33",
  332 + "\x81\x30\x88\x34", "\x81\x30\x88\x35", "\x81\x30\x88\x36", "\x81\x30\x88\x37",
  333 + "\x81\x30\x88\x38", "\x81\x30\x88\x39", "\x81\x30\x89\x30", "\xa1\xc1",
  334 + "\x81\x30\x89\x31", "\x81\x30\x89\x32", "\x81\x30\x89\x33", "\x81\x30\x89\x34",
  335 + "\x81\x30\x89\x35", "\x81\x30\x89\x36", "\x81\x30\x89\x37", "\x81\x30\x89\x38",
  336 + "\xa8\xa4", "\xa8\xa2", "\x81\x30\x89\x39", "\x81\x30\x8a\x30",
  337 + "\x81\x30\x8a\x31", "\x81\x30\x8a\x32", "\x81\x30\x8a\x33", "\x81\x30\x8a\x34",
  338 + "\xa8\xa8", "\xa8\xa6", "\xa8\xba", "\x81\x30\x8a\x35",
  339 + "\xa8\xac", "\xa8\xaa", "\x81\x30\x8a\x36", "\x81\x30\x8a\x37",
  340 + "\x81\x30\x8a\x38", "\x81\x30\x8a\x39", "\xa8\xb0", "\xa8\xae",
  341 + "\x81\x30\x8b\x30", "\x81\x30\x8b\x31", "\x81\x30\x8b\x32", "\xa1\xc2",
  342 + "\x81\x30\x8b\x33", "\xa8\xb4", "\xa8\xb2", "\x81\x30\x8b\x34",
  343 + "\xa8\xb9", "\x81\x30\x8b\x35", "\x81\x30\x8b\x36", "\x81\x30\x8b\x37"
  344 +}
  345 +#endif
  346 +};
  347 +*/
  348 +/*
  349 + * Look up a multi-byte UTF-8 string and return its value in the 'implied'
  350 + * character set.
  351 + * Returns 0 if the lookup fails.
  352 + */
  353 +unsigned char utf8_lookup(char GNUC_UNUSED(*mbs), enum ulfail *fail, int GNUC_UNUSED(*consumed))
  354 +{
  355 + if (fail != NULL)
  356 + *fail = ULFAIL_NOUTF8;
  357 +
  358 + return 0;
  359 +}
... ...
src/core/charset/view.c 0 → 100644
... ... @@ -0,0 +1,131 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como charset.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + * licinio@bb.com.br (Licínio Luis Branco)
  28 + * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
  29 + *
  30 + */
  31 +
  32 +/**
  33 + * @file charset/view.c
  34 + *
  35 + * @brief This module shows the charset table.
  36 + */
  37 +
  38 +#include <lib3270-internals.h>
  39 +#include <lib3270/charset.h>
  40 +#include <lib3270/log.h>
  41 +#include <lib3270/trace.h>
  42 +
  43 +/*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
  44 +
  45 +LIB3270_EXPORT int lib3270_charsettable(H3270 *hSession)
  46 +{
  47 + static const char * hChars = "0123456789ABCDEF";
  48 + static const char * label = "Name:";
  49 +
  50 + int f;
  51 + int margin_left = 5;
  52 + int baddr;
  53 + int chr;
  54 + int s,r;
  55 + const char *ptr;
  56 +
  57 + CHECK_SESSION_HANDLE(hSession);
  58 +
  59 + trace("%s","Showing charset table");
  60 +
  61 + (void) memset((char *) hSession->ea_buf, 0, hSession->view.rows * hSession->view.cols * sizeof(struct lib3270_ea));
  62 +
  63 + baddr = margin_left+hSession->max.cols;
  64 + s = (hSession->max.cols * 0x11);
  65 + for(f=4;f<=0x0f;f++)
  66 + {
  67 + baddr += 2;
  68 + hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY;
  69 + hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
  70 + hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
  71 + hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
  72 + hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
  73 + }
  74 +
  75 + baddr = margin_left+(hSession->max.cols*2);
  76 + s = 0x1a;
  77 + for(f=0;f<=0x0f;f++)
  78 + {
  79 + hSession->ea_buf[baddr+s].fg = hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_GRAY;
  80 + hSession->ea_buf[baddr+s].bg = hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
  81 + hSession->ea_buf[baddr+s].cs = hSession->ea_buf[baddr].cs = 0;
  82 + hSession->ea_buf[baddr+s].cc = hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) hChars[f]];
  83 + hSession->ea_buf[baddr+s].gr = hSession->ea_buf[baddr].gr = 0;
  84 + baddr += hSession->max.cols;
  85 + }
  86 +
  87 + chr = 0x40;
  88 +
  89 + for(f=0;f<0x0c;f++)
  90 + {
  91 + baddr = (margin_left+(hSession->max.cols*2))+(f*2)+2;
  92 + for(r=0;r<=0x0f;r++)
  93 + {
  94 + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
  95 + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
  96 + hSession->ea_buf[baddr].cs = 0;
  97 + hSession->ea_buf[baddr].cc = chr++;
  98 + hSession->ea_buf[baddr].gr = 0;
  99 + baddr += hSession->max.cols;
  100 + }
  101 + }
  102 +
  103 + baddr = margin_left+0x1d+(hSession->max.cols*2);
  104 + for(ptr=label;*ptr;ptr++)
  105 + {
  106 + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_WHITE;
  107 + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
  108 + hSession->ea_buf[baddr].cs = 0;
  109 + hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr];
  110 + hSession->ea_buf[baddr].gr = 0;
  111 + baddr++;
  112 + }
  113 + baddr++;
  114 +
  115 + for(ptr=hSession->charset.host;*ptr;ptr++)
  116 + {
  117 + hSession->ea_buf[baddr].fg = LIB3270_ATTR_COLOR_YELLOW;
  118 + hSession->ea_buf[baddr].bg = LIB3270_ATTR_COLOR_BLACK;
  119 + hSession->ea_buf[baddr].cs = 0;
  120 + hSession->ea_buf[baddr].cc = hSession->charset.asc2ebc[(int) *ptr];
  121 + hSession->ea_buf[baddr].gr = 0;
  122 + baddr++;
  123 + }
  124 +
  125 + hSession->cbk.display(hSession);
  126 +
  127 + return 0;
  128 +}
  129 +
  130 +
  131 +
... ...
src/core/utf8.c
... ... @@ -1,359 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como utf8.c e possui 514 linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - * licinio@bb.com.br (Licínio Luis Branco)
28   - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)
29   - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda)
30   - *
31   - */
32   -
33   -/**
34   - * @file utf8.c
35   - * @brief 3270 Terminal Emulator UTF-8 conversions
36   - */
37   -
38   -#include <lib3270-internals.h>
39   -// #include "api.h"
40   -
41   -#include "popupsc.h"
42   -#include "utf8c.h"
43   -
44   -// char *locale_codeset = CN;
45   -
46   -// static int utf8_ix = -1;
47   -
48   -// static Boolean is_utf8 = False;
49   -#if defined(X3270_DBCS) /*[*/
50   -static Boolean is_gb18030 = False;
51   -#endif /*]*/
52   -
53   -/* Various types of 8-bit character sets we understand. */
54   -enum UTF_IX {
55   - /* Real translations from 8-bit encodings to UTF-8. */
56   - U_ISO8859_1,
57   - U_ISO8859_2,
58   - U_ISO8859_7,
59   - U_ISO8859_8,
60   - U_ISO8859_9,
61   - U_ISO8859_11,
62   - U_ISO8859_15,
63   - U_KOI8_R,
64   -
65   -#if defined(X3270_DBCS) /*[*/
66   - /* Multi-byte expansions of non-UTF-8 encodings. */
67   - PSEUDO_GB18030,
68   -#endif /*]*/
69   -
70   - U_MAX
71   -};
72   -
73   -/*
74   - * Names of the above (real) character sets. These are the names used in
75   - * displayCharset resources.
76   - */ /*
77   -static char *dcs[] = { // same order as enum UTF_IX and utf8_tab[]
78   - "iso8859-1",
79   - "iso8859-2",
80   - "iso8859-7",
81   - "iso8859-8",
82   - "iso8859-9",
83   - "iso8859-11",
84   - "iso8859-15",
85   - "koi8-r",
86   - CN
87   -};
88   -*/
89   -
90   -/*
91   - * UTF-8 translation tables.
92   - * These are used to convert code points 0xa0 through 0xff to UTF-8.
93   - *
94   - * Note that this could be done much more generally with the iconv library
95   - * or the ICU library, but there is no guarantee that either is available or
96   - * properly configured.
97   - */ /*
98   -#define HI_SIZE 96
99   -static char *utf8_tab[U_MAX][96] = {
100   -
101   - // iso8859-1
102   - {
103   - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
104   - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
105   - "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
106   - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
107   - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
108   - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
109   - "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
110   - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf",
111   - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
112   - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
113   - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
114   - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
115   - "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93",
116   - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
117   - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
118   - "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f",
119   - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
120   - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
121   - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
122   - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
123   - "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
124   - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
125   - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
126   - "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf"
127   -},
128   -// iso8859-2
129   -{
130   - "\xc2\xa0", "\xc4\x84", "\xcb\x98", "\xc5\x81",
131   - "\xc2\xa4", "\xc4\xbd", "\xc5\x9a", "\xc2\xa7",
132   - "\xc2\xa8", "\xc5\xa0", "\xc5\x9e", "\xc5\xa4",
133   - "\xc5\xb9", "\xc2\xad", "\xc5\xbd", "\xc5\xbb",
134   - "\xc2\xb0", "\xc4\x85", "\xcb\x9b", "\xc5\x82",
135   - "\xc2\xb4", "\xc4\xbe", "\xc5\x9b", "\xcb\x87",
136   - "\xc2\xb8", "\xc5\xa1", "\xc5\x9f", "\xc5\xa5",
137   - "\xc5\xba", "\xcb\x9d", "\xc5\xbe", "\xc5\xbc",
138   - "\xc5\x94", "\xc3\x81", "\xc3\x82", "\xc4\x82",
139   - "\xc3\x84", "\xc4\xb9", "\xc4\x86", "\xc3\x87",
140   - "\xc4\x8c", "\xc3\x89", "\xc4\x98", "\xc3\x8b",
141   - "\xc4\x9a", "\xc3\x8d", "\xc3\x8e", "\xc4\x8e",
142   - "\xc4\x90", "\xc5\x83", "\xc5\x87", "\xc3\x93",
143   - "\xc3\x94", "\xc5\x90", "\xc3\x96", "\xc3\x97",
144   - "\xc5\x98", "\xc5\xae", "\xc3\x9a", "\xc5\xb0",
145   - "\xc3\x9c", "\xc3\x9d", "\xc5\xa2", "\xc3\x9f",
146   - "\xc5\x95", "\xc3\xa1", "\xc3\xa2", "\xc4\x83",
147   - "\xc3\xa4", "\xc4\xba", "\xc4\x87", "\xc3\xa7",
148   - "\xc4\x8d", "\xc3\xa9", "\xc4\x99", "\xc3\xab",
149   - "\xc4\x9b", "\xc3\xad", "\xc3\xae", "\xc4\x8f",
150   - "\xc4\x91", "\xc5\x84", "\xc5\x88", "\xc3\xb3",
151   - "\xc3\xb4", "\xc5\x91", "\xc3\xb6", "\xc3\xb7",
152   - "\xc5\x99", "\xc5\xaf", "\xc3\xba", "\xc5\xb1",
153   - "\xc3\xbc", "\xc3\xbd", "\xc5\xa3", "\xcb\x99"
154   -},
155   -// iso8859-7
156   -{
157   - "\xc2\xa0", "\xe2\x80\x98", "\xe2\x80\x99", "\xc2\xa3",
158   - "\xe2\x82\xac", "\xe2\x82\xaf", "\xc2\xa6", "\xc2\xa7",
159   - "\xc2\xa8", "\xc2\xa9", "\xcd\xba", "\xc2\xab",
160   - "\xc2\xac", "\xc2\xad", " ", "\xe2\x80\x95",
161   - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
162   - "\xce\x84", "\xce\x85", "\xce\x86", "\xc2\xb7",
163   - "\xce\x88", "\xce\x89", "\xce\x8a", "\xc2\xbb",
164   - "\xce\x8c", "\xc2\xbd", "\xce\x8e", "\xce\x8f",
165   - "\xce\x90", "\xce\x91", "\xce\x92", "\xce\x93",
166   - "\xce\x94", "\xce\x95", "\xce\x96", "\xce\x97",
167   - "\xce\x98", "\xce\x99", "\xce\x9a", "\xce\x9b",
168   - "\xce\x9c", "\xce\x9d", "\xce\x9e", "\xce\x9f",
169   - "\xce\xa0", "\xce\xa1", " ", "\xce\xa3",
170   - "\xce\xa4", "\xce\xa5", "\xce\xa6", "\xce\xa7",
171   - "\xce\xa8", "\xce\xa9", "\xce\xaa", "\xce\xab",
172   - "\xce\xac", "\xce\xad", "\xce\xae", "\xce\xaf",
173   - "\xce\xb0", "\xce\xb1", "\xce\xb2", "\xce\xb3",
174   - "\xce\xb4", "\xce\xb5", "\xce\xb6", "\xce\xb7",
175   - "\xce\xb8", "\xce\xb9", "\xce\xba", "\xce\xbb",
176   - "\xce\xbc", "\xce\xbd", "\xce\xbe", "\xce\xbf",
177   - "\xcf\x80", "\xcf\x81", "\xcf\x82", "\xcf\x83",
178   - "\xcf\x84", "\xcf\x85", "\xcf\x86", "\xcf\x87",
179   - "\xcf\x88", "\xcf\x89", "\xcf\x8a", "\xcf\x8b",
180   - "\xcf\x8c", "\xcf\x8d", "\xcf\x8e", " "
181   -},
182   -// iso8859-8
183   -{
184   - "\xc2\xa0", " ", "\xc2\xa2", "\xc2\xa3",
185   - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
186   - "\xc2\xa8", "\xc2\xa9", "\xc3\x97", "\xc2\xab",
187   - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
188   - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
189   - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
190   - "\xc2\xb8", "\xc2\xb9", "\xc3\xb7", "\xc2\xbb",
191   - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", " ",
192   - " ", " ", " ", " ",
193   - " ", " ", " ", " ",
194   - " ", " ", " ", " ",
195   - " ", " ", " ", " ",
196   - " ", " ", " ", " ",
197   - " ", " ", " ", " ",
198   - " ", " ", " ", " ",
199   - " ", " ", " ", "\xe2\x80\x97",
200   - "\xd7\x90", "\xd7\x91", "\xd7\x92", "\xd7\x93",
201   - "\xd7\x94", "\xd7\x95", "\xd7\x96", "\xd7\x97",
202   - "\xd7\x98", "\xd7\x99", "\xd7\x9a", "\xd7\x9b",
203   - "\xd7\x9c", "\xd7\x9d", "\xd7\x9e", "\xd7\x9f",
204   - "\xd7\xa0", "\xd7\xa1", "\xd7\xa2", "\xd7\xa3",
205   - "\xd7\xa4", "\xd7\xa5", "\xd7\xa6", "\xd7\xa7",
206   - "\xd7\xa8", "\xd7\xa9", "\xd7\xaa", " ",
207   - " ", "\xe2\x80\x8e", "\xe2\x80\x8f", " "
208   -},
209   -// iso8859-9
210   -{
211   - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
212   - "\xc2\xa4", "\xc2\xa5", "\xc2\xa6", "\xc2\xa7",
213   - "\xc2\xa8", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
214   - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
215   - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
216   - "\xc2\xb4", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
217   - "\xc2\xb8", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
218   - "\xc2\xbc", "\xc2\xbd", "\xc2\xbe", "\xc2\xbf",
219   - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
220   - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
221   - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
222   - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
223   - "\xc4\x9e", "\xc3\x91", "\xc3\x92", "\xc3\x93",
224   - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
225   - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
226   - "\xc3\x9c", "\xc4\xb0", "\xc5\x9e", "\xc3\x9f",
227   - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
228   - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
229   - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
230   - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
231   - "\xc4\x9f", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
232   - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
233   - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
234   - "\xc3\xbc", "\xc4\xb1", "\xc5\x9f", "\xc3\xbf"
235   -},
236   -// iso8859-11
237   -{
238   - "\xc2\xa0", "\xe0\xb8\x81", "\xe0\xb8\x82", "\xe0\xb8\x83",
239   - "\xe0\xb8\x84", "\xe0\xb8\x85", "\xe0\xb8\x86", "\xe0\xb8\x87",
240   - "\xe0\xb8\x88", "\xe0\xb8\x89", "\xe0\xb8\x8a", "\xe0\xb8\x8b",
241   - "\xe0\xb8\x8c", "\xe0\xb8\x8d", "\xe0\xb8\x8e", "\xe0\xb8\x8f",
242   - "\xe0\xb8\x90", "\xe0\xb8\x91", "\xe0\xb8\x92", "\xe0\xb8\x93",
243   - "\xe0\xb8\x94", "\xe0\xb8\x95", "\xe0\xb8\x96", "\xe0\xb8\x97",
244   - "\xe0\xb8\x98", "\xe0\xb8\x99", "\xe0\xb8\x9a", "\xe0\xb8\x9b",
245   - "\xe0\xb8\x9c", "\xe0\xb8\x9d", "\xe0\xb8\x9e", "\xe0\xb8\x9f",
246   - "\xe0\xb8\xa0", "\xe0\xb8\xa1", "\xe0\xb8\xa2", "\xe0\xb8\xa3",
247   - "\xe0\xb8\xa4", "\xe0\xb8\xa5", "\xe0\xb8\xa6", "\xe0\xb8\xa7",
248   - "\xe0\xb8\xa8", "\xe0\xb8\xa9", "\xe0\xb8\xaa", "\xe0\xb8\xab",
249   - "\xe0\xb8\xac", "\xe0\xb8\xad", "\xe0\xb8\xae", "\xe0\xb8\xaf",
250   - "\xe0\xb8\xb0", "\xe0\xb8\xb1", "\xe0\xb8\xb2", "\xe0\xb8\xb3",
251   - "\xe0\xb8\xb4", "\xe0\xb8\xb5", "\xe0\xb8\xb6", "\xe0\xb8\xb7",
252   - "\xe0\xb8\xb8", "\xe0\xb8\xb9", "\xe0\xb8\xba", " ",
253   - " ", " ", " ", "\xe0\xb8\xbf",
254   - "\xe0\xb9\x80", "\xe0\xb9\x81", "\xe0\xb9\x82", "\xe0\xb9\x83",
255   - "\xe0\xb9\x84", "\xe0\xb9\x85", "\xe0\xb9\x86", "\xe0\xb9\x87",
256   - "\xe0\xb9\x88", "\xe0\xb9\x89", "\xe0\xb9\x8a", "\xe0\xb9\x8b",
257   - "\xe0\xb9\x8c", "\xe0\xb9\x8d", "\xe0\xb9\x8e", "\xe0\xb9\x8f",
258   - "\xe0\xb9\x90", "\xe0\xb9\x91", "\xe0\xb9\x92", "\xe0\xb9\x93",
259   - "\xe0\xb9\x94", "\xe0\xb9\x95", "\xe0\xb9\x96", "\xe0\xb9\x97",
260   - "\xe0\xb9\x98", "\xe0\xb9\x99", "\xe0\xb9\x9a", "\xe0\xb9\x9b",
261   - " ", " ", " ", " "
262   -},
263   -// iso8859-15
264   -{
265   - "\xc2\xa0", "\xc2\xa1", "\xc2\xa2", "\xc2\xa3",
266   - "\xe2\x82\xac", "\xc2\xa5", "\xc5\xa0", "\xc2\xa7",
267   - "\xc5\xa1", "\xc2\xa9", "\xc2\xaa", "\xc2\xab",
268   - "\xc2\xac", "\xc2\xad", "\xc2\xae", "\xc2\xaf",
269   - "\xc2\xb0", "\xc2\xb1", "\xc2\xb2", "\xc2\xb3",
270   - "\xc5\xbd", "\xc2\xb5", "\xc2\xb6", "\xc2\xb7",
271   - "\xc5\xbe", "\xc2\xb9", "\xc2\xba", "\xc2\xbb",
272   - "\xc5\x92", "\xc5\x93", "\xc5\xb8", "\xc2\xbf",
273   - "\xc3\x80", "\xc3\x81", "\xc3\x82", "\xc3\x83",
274   - "\xc3\x84", "\xc3\x85", "\xc3\x86", "\xc3\x87",
275   - "\xc3\x88", "\xc3\x89", "\xc3\x8a", "\xc3\x8b",
276   - "\xc3\x8c", "\xc3\x8d", "\xc3\x8e", "\xc3\x8f",
277   - "\xc3\x90", "\xc3\x91", "\xc3\x92", "\xc3\x93",
278   - "\xc3\x94", "\xc3\x95", "\xc3\x96", "\xc3\x97",
279   - "\xc3\x98", "\xc3\x99", "\xc3\x9a", "\xc3\x9b",
280   - "\xc3\x9c", "\xc3\x9d", "\xc3\x9e", "\xc3\x9f",
281   - "\xc3\xa0", "\xc3\xa1", "\xc3\xa2", "\xc3\xa3",
282   - "\xc3\xa4", "\xc3\xa5", "\xc3\xa6", "\xc3\xa7",
283   - "\xc3\xa8", "\xc3\xa9", "\xc3\xaa", "\xc3\xab",
284   - "\xc3\xac", "\xc3\xad", "\xc3\xae", "\xc3\xaf",
285   - "\xc3\xb0", "\xc3\xb1", "\xc3\xb2", "\xc3\xb3",
286   - "\xc3\xb4", "\xc3\xb5", "\xc3\xb6", "\xc3\xb7",
287   - "\xc3\xb8", "\xc3\xb9", "\xc3\xba", "\xc3\xbb",
288   - "\xc3\xbc", "\xc3\xbd", "\xc3\xbe", "\xc3\xbf"
289   -},
290   -// koi8-r
291   -{
292   - "\xe2\x95\x90", "\xe2\x95\x91", "\xe2\x95\x92", "\xd1\x91",
293   - "\xe2\x95\x93", "\xe2\x95\x94", "\xe2\x95\x95", "\xe2\x95\x96",
294   - "\xe2\x95\x97", "\xe2\x95\x98", "\xe2\x95\x99", "\xe2\x95\x9a",
295   - "\xe2\x95\x9b", "\xe2\x95\x9c", "\xe2\x95\x9d", "\xe2\x95\x9e",
296   - "\xe2\x95\x9f", "\xe2\x95\xa0", "\xe2\x95\xa1", "\xd0\x81",
297   - "\xe2\x95\xa2", "\xe2\x95\xa3", "\xe2\x95\xa4", "\xe2\x95\xa5",
298   - "\xe2\x95\xa6", "\xe2\x95\xa7", "\xe2\x95\xa8", "\xe2\x95\xa9",
299   - "\xe2\x95\xaa", "\xe2\x95\xab", "\xe2\x95\xac", "\xc2\xa9",
300   - "\xd1\x8e", "\xd0\xb0", "\xd0\xb1", "\xd1\x86",
301   - "\xd0\xb4", "\xd0\xb5", "\xd1\x84", "\xd0\xb3",
302   - "\xd1\x85", "\xd0\xb8", "\xd0\xb9", "\xd0\xba",
303   - "\xd0\xbb", "\xd0\xbc", "\xd0\xbd", "\xd0\xbe",
304   - "\xd0\xbf", "\xd1\x8f", "\xd1\x80", "\xd1\x81",
305   - "\xd1\x82", "\xd1\x83", "\xd0\xb6", "\xd0\xb2",
306   - "\xd1\x8c", "\xd1\x8b", "\xd0\xb7", "\xd1\x88",
307   - "\xd1\x8d", "\xd1\x89", "\xd1\x87", "\xd1\x8a",
308   - "\xd0\xae", "\xd0\x90", "\xd0\x91", "\xd0\xa6",
309   - "\xd0\x94", "\xd0\x95", "\xd0\xa4", "\xd0\x93",
310   - "\xd0\xa5", "\xd0\x98", "\xd0\x99", "\xd0\x9a",
311   - "\xd0\x9b", "\xd0\x9c", "\xd0\x9d", "\xd0\x9e",
312   - "\xd0\x9f", "\xd0\xaf", "\xd0\xa0", "\xd0\xa1",
313   - "\xd0\xa2", "\xd0\xa3", "\xd0\x96", "\xd0\x92",
314   - "\xd0\xac", "\xd0\xab", "\xd0\x97", "\xd0\xa8",
315   - "\xd0\xad", "\xd0\xa9", "\xd0\xa7", "\xd0\xaa"
316   -},
317   -#if defined(X3270_DBCS)
318   -// pseudo-gb18030 - not actually a UTF-8 expansion
319   -{
320   - "\x81\x30\x84\x32", "\x81\x30\x84\x33", "\x81\x30\x84\x34", "\x81\x30\x84\x35",
321   - "\xa1\xe8", "\x81\x30\x84\x36", "\x81\x30\x84\x37", "\xa1\xec",
322   - "\xa1\xa7", "\x81\x30\x84\x38", "\x81\x30\x84\x39", "\x81\x30\x85\x30",
323   - "\x81\x30\x85\x31", "\x81\x30\x85\x32", "\x81\x30\x85\x33", "\x81\x30\x85\x34",
324   - "\xa1\xe3", "\xa1\xc0", "\x81\x30\x85\x35", "\x81\x30\x85\x36",
325   - "\x81\x30\x85\x37", "\x81\x30\x85\x38", "\x81\x30\x85\x39", "\xa1\xa4",
326   - "\x81\x30\x86\x30", "\x81\x30\x86\x31", "\x81\x30\x86\x32", "\x81\x30\x86\x33",
327   - "\x81\x30\x86\x34", "\x81\x30\x86\x35", "\x81\x30\x86\x36", "\x81\x30\x86\x37",
328   - "\x81\x30\x86\x38", "\x81\x30\x86\x39", "\x81\x30\x87\x30", "\x81\x30\x87\x31",
329   - "\x81\x30\x87\x32", "\x81\x30\x87\x33", "\x81\x30\x87\x34", "\x81\x30\x87\x35",
330   - "\x81\x30\x87\x36", "\x81\x30\x87\x37", "\x81\x30\x87\x38", "\x81\x30\x87\x39",
331   - "\x81\x30\x88\x30", "\x81\x30\x88\x31", "\x81\x30\x88\x32", "\x81\x30\x88\x33",
332   - "\x81\x30\x88\x34", "\x81\x30\x88\x35", "\x81\x30\x88\x36", "\x81\x30\x88\x37",
333   - "\x81\x30\x88\x38", "\x81\x30\x88\x39", "\x81\x30\x89\x30", "\xa1\xc1",
334   - "\x81\x30\x89\x31", "\x81\x30\x89\x32", "\x81\x30\x89\x33", "\x81\x30\x89\x34",
335   - "\x81\x30\x89\x35", "\x81\x30\x89\x36", "\x81\x30\x89\x37", "\x81\x30\x89\x38",
336   - "\xa8\xa4", "\xa8\xa2", "\x81\x30\x89\x39", "\x81\x30\x8a\x30",
337   - "\x81\x30\x8a\x31", "\x81\x30\x8a\x32", "\x81\x30\x8a\x33", "\x81\x30\x8a\x34",
338   - "\xa8\xa8", "\xa8\xa6", "\xa8\xba", "\x81\x30\x8a\x35",
339   - "\xa8\xac", "\xa8\xaa", "\x81\x30\x8a\x36", "\x81\x30\x8a\x37",
340   - "\x81\x30\x8a\x38", "\x81\x30\x8a\x39", "\xa8\xb0", "\xa8\xae",
341   - "\x81\x30\x8b\x30", "\x81\x30\x8b\x31", "\x81\x30\x8b\x32", "\xa1\xc2",
342   - "\x81\x30\x8b\x33", "\xa8\xb4", "\xa8\xb2", "\x81\x30\x8b\x34",
343   - "\xa8\xb9", "\x81\x30\x8b\x35", "\x81\x30\x8b\x36", "\x81\x30\x8b\x37"
344   -}
345   -#endif
346   -};
347   -*/
348   -/*
349   - * Look up a multi-byte UTF-8 string and return its value in the 'implied'
350   - * character set.
351   - * Returns 0 if the lookup fails.
352   - */
353   -unsigned char utf8_lookup(char GNUC_UNUSED(*mbs), enum ulfail *fail, int GNUC_UNUSED(*consumed))
354   -{
355   - if (fail != NULL)
356   - *fail = ULFAIL_NOUTF8;
357   -
358   - return 0;
359   -}