~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Externals/libiconv-1.14/lib/koi8_t.h

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/*
 
22
 * KOI8-T
 
23
 */
 
24
 
 
25
static const unsigned short koi8_t_2uni[128] = {
 
26
  /* 0x80 */
 
27
  0x049b, 0x0493, 0x201a, 0x0492, 0x201e, 0x2026, 0x2020, 0x2021,
 
28
  0xfffd, 0x2030, 0x04b3, 0x2039, 0x04b2, 0x04b7, 0x04b6, 0xfffd,
 
29
  /* 0x90 */
 
30
  0x049a, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
 
31
  0xfffd, 0x2122, 0xfffd, 0x203a, 0xfffd, 0xfffd, 0xfffd, 0xfffd,
 
32
  /* 0xa0 */
 
33
  0xfffd, 0x04ef, 0x04ee, 0x0451, 0x00a4, 0x04e3, 0x00a6, 0x00a7,
 
34
  0xfffd, 0xfffd, 0xfffd, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0xfffd,
 
35
  /* 0xb0 */
 
36
  0x00b0, 0x00b1, 0x00b2, 0x0401, 0xfffd, 0x04e2, 0x00b6, 0x00b7,
 
37
  0xfffd, 0x2116, 0xfffd, 0x00bb, 0xfffd, 0xfffd, 0xfffd, 0x00a9,
 
38
  /* 0xc0 */
 
39
  0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
 
40
  0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
 
41
  /* 0xd0 */
 
42
  0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
 
43
  0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
 
44
  /* 0xe0 */
 
45
  0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
 
46
  0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
 
47
  /* 0xf0 */
 
48
  0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
 
49
  0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a,
 
50
};
 
51
 
 
52
static int
 
53
koi8_t_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
 
54
{
 
55
  unsigned char c = *s;
 
56
  if (c < 0x80) {
 
57
    *pwc = (ucs4_t) c;
 
58
    return 1;
 
59
  }
 
60
  else {
 
61
    unsigned short wc = koi8_t_2uni[c-0x80];
 
62
    if (wc != 0xfffd) {
 
63
      *pwc = (ucs4_t) wc;
 
64
      return 1;
 
65
    }
 
66
  }
 
67
  return RET_ILSEQ;
 
68
}
 
69
 
 
70
static const unsigned char koi8_t_page00[32] = {
 
71
  0x00, 0x00, 0x00, 0x00, 0xa4, 0x00, 0xa6, 0xa7, /* 0xa0-0xa7 */
 
72
  0x00, 0xbf, 0x00, 0xab, 0xac, 0xad, 0xae, 0x00, /* 0xa8-0xaf */
 
73
  0xb0, 0xb1, 0xb2, 0x00, 0x00, 0x00, 0xb6, 0xb7, /* 0xb0-0xb7 */
 
74
  0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
 
75
};
 
76
static const unsigned char koi8_t_page04[240] = {
 
77
  0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */
 
78
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */
 
79
  0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, /* 0x10-0x17 */
 
80
  0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, /* 0x18-0x1f */
 
81
  0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, /* 0x20-0x27 */
 
82
  0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, /* 0x28-0x2f */
 
83
  0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, /* 0x30-0x37 */
 
84
  0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, /* 0x38-0x3f */
 
85
  0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, /* 0x40-0x47 */
 
86
  0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, /* 0x48-0x4f */
 
87
  0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */
 
88
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */
 
89
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */
 
90
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */
 
91
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */
 
92
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */
 
93
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */
 
94
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */
 
95
  0x00, 0x00, 0x83, 0x81, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */
 
96
  0x00, 0x00, 0x90, 0x80, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */
 
97
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */
 
98
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */
 
99
  0x00, 0x00, 0x8c, 0x8a, 0x00, 0x00, 0x8e, 0x8d, /* 0xb0-0xb7 */
 
100
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */
 
101
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0-0xc7 */
 
102
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */
 
103
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */
 
104
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8-0xdf */
 
105
  0x00, 0x00, 0xb5, 0xa5, 0x00, 0x00, 0x00, 0x00, /* 0xe0-0xe7 */
 
106
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0xa1, /* 0xe8-0xef */
 
107
};
 
108
static const unsigned char koi8_t_page20[48] = {
 
109
  0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */
 
110
  0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */
 
111
  0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */
 
112
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */
 
113
  0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */
 
114
  0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */
 
115
};
 
116
static const unsigned char koi8_t_page21[24] = {
 
117
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb9, 0x00, /* 0x10-0x17 */
 
118
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */
 
119
  0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */
 
120
};
 
121
 
 
122
static int
 
123
koi8_t_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
 
124
{
 
125
  unsigned char c = 0;
 
126
  if (wc < 0x0080) {
 
127
    *r = wc;
 
128
    return 1;
 
129
  }
 
130
  else if (wc >= 0x00a0 && wc < 0x00c0)
 
131
    c = koi8_t_page00[wc-0x00a0];
 
132
  else if (wc >= 0x0400 && wc < 0x04f0)
 
133
    c = koi8_t_page04[wc-0x0400];
 
134
  else if (wc >= 0x2010 && wc < 0x2040)
 
135
    c = koi8_t_page20[wc-0x2010];
 
136
  else if (wc >= 0x2110 && wc < 0x2128)
 
137
    c = koi8_t_page21[wc-0x2110];
 
138
  if (c != 0) {
 
139
    *r = c;
 
140
    return 1;
 
141
  }
 
142
  return RET_ILUNI;
 
143
}