tds565.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (C) 1999-2002 Free Software Foundation, Inc.
  3. * This file is part of the GNU LIBICONV Library.
  4. *
  5. * The GNU LIBICONV Library is free software; you can redistribute it
  6. * and/or modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * The GNU LIBICONV Library is distributed in the hope that it will be
  11. * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public
  16. * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
  17. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
  18. * Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. /*
  21. * TDS565
  22. */
  23. static const unsigned short tds565_2uni[64] = {
  24. /* 0x40 */
  25. 0x0040, 0x0041, 0x0042, 0x00c7, 0x0044, 0x0045, 0x00c4, 0x0046,
  26. 0x0047, 0x0048, 0x0049, 0x004a, 0x017d, 0x004b, 0x004c, 0x004d,
  27. /* 0x50 */
  28. 0x004e, 0x0147, 0x004f, 0x00d6, 0x0050, 0x0052, 0x0053, 0x015e,
  29. 0x0054, 0x0055, 0x00dc, 0x0057, 0x0059, 0x00dd, 0x005a, 0x005f,
  30. /* 0x60 */
  31. 0x2116, 0x0061, 0x0062, 0x00e7, 0x0064, 0x0065, 0x00e4, 0x0066,
  32. 0x0067, 0x0068, 0x0069, 0x006a, 0x017e, 0x006b, 0x006c, 0x006d,
  33. /* 0x70 */
  34. 0x006e, 0x0148, 0x006f, 0x00f6, 0x0070, 0x0072, 0x0073, 0x015f,
  35. 0x0074, 0x0075, 0x00fc, 0x0077, 0x0079, 0x00fd, 0x007a, 0x007f,
  36. };
  37. static int
  38. tds565_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
  39. {
  40. unsigned char c = *s;
  41. if (c < 0x40) {
  42. *pwc = (ucs4_t) c;
  43. return 1;
  44. }
  45. else if (c < 0x80) {
  46. *pwc = (ucs4_t) tds565_2uni[c-0x40];
  47. return 1;
  48. }
  49. return RET_ILSEQ;
  50. }
  51. static const unsigned char tds565_page00[64] = {
  52. 0x40, 0x41, 0x42, 0x00, 0x44, 0x45, 0x47, 0x48, /* 0x40-0x47 */
  53. 0x49, 0x4a, 0x4b, 0x4d, 0x4e, 0x4f, 0x50, 0x52, /* 0x48-0x4f */
  54. 0x54, 0x00, 0x55, 0x56, 0x58, 0x59, 0x00, 0x5b, /* 0x50-0x57 */
  55. 0x00, 0x5c, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x5f, /* 0x58-0x5f */
  56. 0x00, 0x61, 0x62, 0x00, 0x64, 0x65, 0x67, 0x68, /* 0x60-0x67 */
  57. 0x69, 0x6a, 0x6b, 0x6d, 0x6e, 0x6f, 0x70, 0x72, /* 0x68-0x6f */
  58. 0x74, 0x00, 0x75, 0x76, 0x78, 0x79, 0x00, 0x7b, /* 0x70-0x77 */
  59. 0x00, 0x7c, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f, /* 0x78-0x7f */
  60. };
  61. static const unsigned char tds565_page00_1[64] = {
  62. 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x43, /* 0xc0-0xc7 */
  63. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
  64. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, /* 0xd0-0xd7 */
  65. 0x00, 0x00, 0x00, 0x00, 0x5a, 0x5d, 0x00, 0x00, /* 0xd8-0xdf */
  66. 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x63, /* 0xe0-0xe7 */
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
  68. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, /* 0xf0-0xf7 */
  69. 0x00, 0x00, 0x00, 0x00, 0x7a, 0x7d, 0x00, 0x00, /* 0xf8-0xff */
  70. };
  71. static const unsigned char tds565_page01[64] = {
  72. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, /* 0x40-0x47 */
  73. 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */
  74. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
  75. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x77, /* 0x58-0x5f */
  76. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
  77. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
  78. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
  79. 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x6c, 0x00, /* 0x78-0x7f */
  80. };
  81. static int
  82. tds565_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
  83. {
  84. unsigned char c = 0;
  85. if (wc < 0x0040) {
  86. *r = wc;
  87. return 1;
  88. }
  89. else if (wc >= 0x0040 && wc < 0x0080)
  90. c = tds565_page00[wc-0x0040];
  91. else if (wc >= 0x00c0 && wc < 0x0100)
  92. c = tds565_page00_1[wc-0x00c0];
  93. else if (wc >= 0x0140 && wc < 0x0180)
  94. c = tds565_page01[wc-0x0140];
  95. else if (wc == 0x2116)
  96. c = 0x60;
  97. if (c != 0) {
  98. *r = c;
  99. return 1;
  100. }
  101. return RET_ILUNI;
  102. }