riscos1.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * RISCOS-LATIN1
  22. */
  23. static const unsigned short riscos1_2uni[32] = {
  24. /* 0x80 */
  25. 0x221a, 0x0174, 0x0175, 0x0083, 0x2573, 0x0176, 0x0177, 0x0087,
  26. 0x21e6, 0x21e8, 0x21e9, 0x21e7, 0x2026, 0x2122, 0x2030, 0x2022,
  27. /* 0x90 */
  28. 0x2018, 0x2019, 0x2039, 0x203a, 0x201c, 0x201d, 0x201e, 0x2013,
  29. 0x2014, 0x2212, 0x0152, 0x0153, 0x2020, 0x2021, 0xfb01, 0xfb02,
  30. };
  31. static int
  32. riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
  33. {
  34. unsigned char c = *s;
  35. if (c >= 0x80 && c < 0xa0)
  36. *pwc = (ucs4_t) riscos1_2uni[c-0x80];
  37. else
  38. *pwc = (ucs4_t) c;
  39. return 1;
  40. }
  41. static const unsigned char riscos1_page01[40] = {
  42. 0x00, 0x00, 0x9a, 0x9b, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
  43. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
  45. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
  46. 0x00, 0x00, 0x00, 0x00, 0x81, 0x82, 0x85, 0x86, /* 0x70-0x77 */
  47. };
  48. static const unsigned char riscos1_page20[48] = {
  49. 0x00, 0x00, 0x00, 0x97, 0x98, 0x00, 0x00, 0x00, /* 0x10-0x17 */
  50. 0x90, 0x91, 0x00, 0x00, 0x94, 0x95, 0x96, 0x00, /* 0x18-0x1f */
  51. 0x9c, 0x9d, 0x8f, 0x00, 0x00, 0x00, 0x8c, 0x00, /* 0x20-0x27 */
  52. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
  53. 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
  54. 0x00, 0x92, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
  55. };
  56. static const unsigned char riscos1_page21[16] = {
  57. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x8b, /* 0xe0-0xe7 */
  58. 0x89, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
  59. };
  60. static const unsigned char riscos1_page22[16] = {
  61. 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
  62. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
  63. };
  64. static int
  65. riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
  66. {
  67. unsigned char c = 0;
  68. if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) {
  69. *r = wc;
  70. return 1;
  71. }
  72. else if (wc >= 0x0150 && wc < 0x0178)
  73. c = riscos1_page01[wc-0x0150];
  74. else if (wc >= 0x2010 && wc < 0x2040)
  75. c = riscos1_page20[wc-0x2010];
  76. else if (wc == 0x2122)
  77. c = 0x8d;
  78. else if (wc >= 0x21e0 && wc < 0x21f0)
  79. c = riscos1_page21[wc-0x21e0];
  80. else if (wc >= 0x2210 && wc < 0x2220)
  81. c = riscos1_page22[wc-0x2210];
  82. else if (wc == 0x2573)
  83. c = 0x84;
  84. else if (wc >= 0xfb01 && wc < 0xfb03)
  85. c = wc-0xfa63;
  86. if (c != 0) {
  87. *r = c;
  88. return 1;
  89. }
  90. return RET_ILUNI;
  91. }