riscos1.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 1999-2002, 2016 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 Lesser General Public
  7. * License as published by the Free Software Foundation; either version 2.1
  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. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
  17. * If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * RISCOS-LATIN1
  21. */
  22. static const unsigned short riscos1_2uni[32] = {
  23. /* 0x80 */
  24. 0x221a, 0x0174, 0x0175, 0x0083, 0x2573, 0x0176, 0x0177, 0x0087,
  25. 0x21e6, 0x21e8, 0x21e9, 0x21e7, 0x2026, 0x2122, 0x2030, 0x2022,
  26. /* 0x90 */
  27. 0x2018, 0x2019, 0x2039, 0x203a, 0x201c, 0x201d, 0x201e, 0x2013,
  28. 0x2014, 0x2212, 0x0152, 0x0153, 0x2020, 0x2021, 0xfb01, 0xfb02,
  29. };
  30. static int
  31. riscos1_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
  32. {
  33. unsigned char c = *s;
  34. if (c >= 0x80 && c < 0xa0)
  35. *pwc = (ucs4_t) riscos1_2uni[c-0x80];
  36. else
  37. *pwc = (ucs4_t) c;
  38. return 1;
  39. }
  40. static const unsigned char riscos1_page01[40] = {
  41. 0x00, 0x00, 0x9a, 0x9b, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
  42. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
  43. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
  44. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
  45. 0x00, 0x00, 0x00, 0x00, 0x81, 0x82, 0x85, 0x86, /* 0x70-0x77 */
  46. };
  47. static const unsigned char riscos1_page20[48] = {
  48. 0x00, 0x00, 0x00, 0x97, 0x98, 0x00, 0x00, 0x00, /* 0x10-0x17 */
  49. 0x90, 0x91, 0x00, 0x00, 0x94, 0x95, 0x96, 0x00, /* 0x18-0x1f */
  50. 0x9c, 0x9d, 0x8f, 0x00, 0x00, 0x00, 0x8c, 0x00, /* 0x20-0x27 */
  51. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
  52. 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
  53. 0x00, 0x92, 0x93, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
  54. };
  55. static const unsigned char riscos1_page21[16] = {
  56. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x8b, /* 0xe0-0xe7 */
  57. 0x89, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8-0xef */
  58. };
  59. static const unsigned char riscos1_page22[16] = {
  60. 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */
  61. 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
  62. };
  63. static int
  64. riscos1_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
  65. {
  66. unsigned char c = 0;
  67. if (wc < 0x0080 || wc == 0x0083 || wc == 0x0087 || (wc >= 0x00a0 && wc < 0x0100)) {
  68. *r = wc;
  69. return 1;
  70. }
  71. else if (wc >= 0x0150 && wc < 0x0178)
  72. c = riscos1_page01[wc-0x0150];
  73. else if (wc >= 0x2010 && wc < 0x2040)
  74. c = riscos1_page20[wc-0x2010];
  75. else if (wc == 0x2122)
  76. c = 0x8d;
  77. else if (wc >= 0x21e0 && wc < 0x21f0)
  78. c = riscos1_page21[wc-0x21e0];
  79. else if (wc >= 0x2210 && wc < 0x2220)
  80. c = riscos1_page22[wc-0x2210];
  81. else if (wc == 0x2573)
  82. c = 0x84;
  83. else if (wc >= 0xfb01 && wc < 0xfb03)
  84. c = wc-0xfa63;
  85. if (c != 0) {
  86. *r = c;
  87. return 1;
  88. }
  89. return RET_ILUNI;
  90. }