468 #ifdef _EUCKR_SUPPORT 469 /************************* EUCKR Specific Operations ************************/ 470 static int euckr_len_first_char (const unsigned char* mstr, int len) 471 { 472 unsigned char ch1; 473 unsigned char ch2; 474 475 if (len < 2) return 0; 476 477 ch1 = mstr [0]; 478 if (ch1 == '\0') 479 return 0; 480 481 ch2 = mstr [1]; 482 if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE) 483 return 2; 484 485 return 0; 486 } 487 488 static int euckr_char_offset (const unsigned char* mchar) 489 { 490 if(mchar [0] > 0xAD) 491 return ((mchar [0] - 0xA4) * 94 + mchar [1] - 0xA1 - 0x8E); 492 else 493 return ((mchar [0] - 0xA1) * 94 + mchar [1] - 0xA1 - 0x8E); 494 } 495 496 static int euckr_is_this_charset (const unsigned char* charset) 497 { 498 int i; 499 char name [LEN_FONT_NAME + 1]; 500 501 for (i = 0; i < LEN_FONT_NAME + 1; i++) { 502 if (charset [i] == '\0') 503 break; 504 name [i] = toupper (charset [i]); 505 } 506 name [i] = '\0'; 507 508 if (strstr (name, "EUCKR") ) 509 return 0; 510 511 return 1; 512 } 513 514 static int euckr_len_first_substr (const unsigned char* mstr, int mstrlen) 515 { 516 unsigned char ch1; 517 unsigned char ch2; 518 int i, left; 519 int sub_len = 0; 520 521 left = mstrlen; 522 for (i = 0; i < mstrlen; i += 2) { 523 if (left < 2) return sub_len; 524 525 ch1 = mstr [i]; 526 if (ch1 == '\0') return sub_len; 527 528 ch2 = mstr [i + 1]; 529 if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE) 530 sub_len += 2; 531 else 532 return sub_len; 533 534 left -= 2; 535 } 536 537 return sub_len; 538 } 539 540 static int euckr_pos_first_char (const unsigned char* mstr, int mstrlen) 541 { 542 unsigned char ch1; 543 unsigned char ch2; 544 int i, left; 545 546 i = 0; 547 left = mstrlen; 548 while (left) { 549 if (left < 2) return -1; 550 551 ch1 = mstr [i]; 552 if (ch1 == '\0') return -1; 553 554 ch2 = mstr [i + 1]; 555 if (ch1 >= 0xA1 && ch1 <= 0xFE && ch2 >= 0xA1 && ch2 <= 0xFE) 556 return i; 557 558 i += 1; 559 left -= 1; 560 } 561 562 return -1; 563 } 564 565 #ifndef _LITE_VERSION 566 static unsigned short euckr_conv_to_uc16 (const unsigned char* mchar, int len) 567 { 568 return '?'; 569 } 570 #endif 571 572 static CHARSETOPS CharsetOps_euckr = { 573 8836, 574 2, 575 2, 576 FONT_CHARSET_EUCKR, 577 {'\xA1', '\xA1'}, 578 euckr_len_first_char, 579 euckr_char_offset, 580 db_nr_chars_in_str, 581 euckr_is_this_charset, 582 euckr_len_first_substr, 583 db_get_next_word, 584 euckr_pos_first_char, 585 #ifndef _LITE_VERSION 586 euckr_conv_to_uc16 587 #endif 588 }; 589 /************************* End of EUCKR *************************************/ 590 #endif /* _EUCKR_SUPPORT */
|