Commit a7267bd73b9c7e3ecd2f59988db2738588a018a5
1 parent
8b27b2ad
Exists in
master
and in
3 other branches
Iniciando implementação do "remap" de caracteres.
Showing
1 changed file
with
21 additions
and
2 deletions
Show diff stats
charset.c
| @@ -255,6 +255,21 @@ static void copy_charset(const unsigned short *from, unsigned short *to) | @@ -255,6 +255,21 @@ static void copy_charset(const unsigned short *from, unsigned short *to) | ||
| 255 | to[f+UT_OFFSET] = from[f]; | 255 | to[f+UT_OFFSET] = from[f]; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | +LIB3270_EXPORT void lib3270_remap(H3270 *hSession,const char *host, const char *display, unsigned long cgcsgid, const unsigned short *chr) | ||
| 259 | +{ | ||
| 260 | + int c; | ||
| 261 | + | ||
| 262 | + hSession->charset.host = host; | ||
| 263 | + hSession->charset.display = display; | ||
| 264 | + hSession->charset.cgcsgid = cgcsgid; | ||
| 265 | + | ||
| 266 | + for(c=0;chr[c];c+=2) | ||
| 267 | + { | ||
| 268 | + lib3270_remap_char(hSession,chr[c],chr[c+1], BOTH, 0); | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | +} | ||
| 272 | + | ||
| 258 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | 273 | LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) |
| 259 | { | 274 | { |
| 260 | int f; | 275 | int f; |
| @@ -271,6 +286,7 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | @@ -271,6 +286,7 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | ||
| 271 | 286 | ||
| 272 | for(f=0;f<UT_OFFSET;f++) | 287 | for(f=0;f<UT_OFFSET;f++) |
| 273 | hSession->charset.asc2uc[f] = f; | 288 | hSession->charset.asc2uc[f] = f; |
| 289 | + | ||
| 274 | copy_charset(asc2uc,hSession->charset.asc2uc); | 290 | copy_charset(asc2uc,hSession->charset.asc2uc); |
| 275 | 291 | ||
| 276 | /* | 292 | /* |
| @@ -288,13 +304,16 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | @@ -288,13 +304,16 @@ LIB3270_EXPORT int lib3270_set_host_charset(H3270 *hSession, const char *name) | ||
| 288 | if(!strcasecmp(name,charset[f].name)) | 304 | if(!strcasecmp(name,charset[f].name)) |
| 289 | { | 305 | { |
| 290 | // Found required charset | 306 | // Found required charset |
| 307 | + lib3270_remap(hSession,charset[f].name,"ISO-8859-1",charset[f].cgcsgid,charset[f].chr); | ||
| 308 | + /* | ||
| 291 | int c; | 309 | int c; |
| 292 | 310 | ||
| 293 | hSession->charset.host = charset[f].name; | 311 | hSession->charset.host = charset[f].name; |
| 294 | hSession->charset.cgcsgid = charset[f].cgcsgid; | 312 | hSession->charset.cgcsgid = charset[f].cgcsgid; |
| 295 | 313 | ||
| 296 | for(c=0;charset[f].chr[c];c+=2) | 314 | for(c=0;charset[f].chr[c];c+=2) |
| 297 | - lib3270_remap(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0); | 315 | + lib3270_remap_char(hSession,charset[f].chr[c],charset[f].chr[c+1], BOTH, 0); |
| 316 | + */ | ||
| 298 | return 0; | 317 | return 0; |
| 299 | } | 318 | } |
| 300 | } | 319 | } |
| @@ -438,7 +457,7 @@ LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buff | @@ -438,7 +457,7 @@ LIB3270_EXPORT const char * lib3270_ebc2asc(H3270 *hSession, unsigned char *buff | ||
| 438 | 457 | ||
| 439 | 458 | ||
| 440 | // Process a single character definition. | 459 | // Process a single character definition. |
| 441 | -LIB3270_EXPORT void lib3270_remap(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) | 460 | +LIB3270_EXPORT void lib3270_remap_char(H3270 *hSession, unsigned short ebc, unsigned short iso, lib3270_remap_scope scope, unsigned char one_way) |
| 442 | { | 461 | { |
| 443 | // unsigned char cg; | 462 | // unsigned char cg; |
| 444 | CHECK_SESSION_HANDLE(hSession); | 463 | CHECK_SESSION_HANDLE(hSession); |