Update ooo320-m1
[ooovba.git] / i18npool / source / transliteration / ignoreProlongedSoundMark_ja_JP.cxx
blobc0e9126e9485164bab80fabfc70bc12e91d5840e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ignoreProlongedSoundMark_ja_JP.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_i18npool.hxx"
34 // prevent internal compiler error with MSVC6SP3
35 #include <utility>
37 #define TRANSLITERATION_ProlongedSoundMark_ja_JP
38 #include <transliteration_Ignore.hxx>
40 using namespace com::sun::star::uno;
41 using namespace com::sun::star::lang;
42 using namespace rtl;
44 namespace com { namespace sun { namespace star { namespace i18n {
46 static sal_Unicode table_normalwidth[] = {
47 // 0x0000, // 0x3040
48 0x3041, // 0x3041 HIRAGANA LETTER SMALL A
49 0x3042, // 0x3042 HIRAGANA LETTER A
50 0x3043, // 0x3043 HIRAGANA LETTER SMALL I
51 0x3044, // 0x3044 HIRAGANA LETTER I
52 0x3045, // 0x3045 HIRAGANA LETTER SMALL U
53 0x3046, // 0x3046 HIRAGANA LETTER U
54 0x3047, // 0x3047 HIRAGANA LETTER SMALL E
55 0x3048, // 0x3048 HIRAGANA LETTER E
56 0x3049, // 0x3049 HIRAGANA LETTER SMALL O
57 0x304a, // 0x304a HIRAGANA LETTER O
58 0x3042, // 0x304b HIRAGANA LETTER KA
59 0x3042, // 0x304c HIRAGANA LETTER GA
60 0x3044, // 0x304d HIRAGANA LETTER KI
61 0x3044, // 0x304e HIRAGANA LETTER GI
62 0x3046, // 0x304f HIRAGANA LETTER KU
63 0x3046, // 0x3050 HIRAGANA LETTER GU
64 0x3048, // 0x3051 HIRAGANA LETTER KE
65 0x3048, // 0x3052 HIRAGANA LETTER GE
66 0x304a, // 0x3053 HIRAGANA LETTER KO
67 0x304a, // 0x3054 HIRAGANA LETTER GO
68 0x3042, // 0x3055 HIRAGANA LETTER SA
69 0x3042, // 0x3056 HIRAGANA LETTER ZA
70 0x3044, // 0x3057 HIRAGANA LETTER SI
71 0x3044, // 0x3058 HIRAGANA LETTER ZI
72 0x3046, // 0x3059 HIRAGANA LETTER SU
73 0x3046, // 0x305a HIRAGANA LETTER ZU
74 0x3048, // 0x305b HIRAGANA LETTER SE
75 0x3048, // 0x305c HIRAGANA LETTER ZE
76 0x304a, // 0x305d HIRAGANA LETTER SO
77 0x304a, // 0x305e HIRAGANA LETTER ZO
78 0x3042, // 0x305f HIRAGANA LETTER TA
79 0x3042, // 0x3060 HIRAGANA LETTER DA
80 0x3044, // 0x3061 HIRAGANA LETTER TI
81 0x3044, // 0x3062 HIRAGANA LETTER DI
82 0x3045, // 0x3063 HIRAGANA LETTER SMALL TU
83 0x3046, // 0x3064 HIRAGANA LETTER TU
84 0x3046, // 0x3065 HIRAGANA LETTER DU
85 0x3048, // 0x3066 HIRAGANA LETTER TE
86 0x3048, // 0x3067 HIRAGANA LETTER DE
87 0x304a, // 0x3068 HIRAGANA LETTER TO
88 0x304a, // 0x3069 HIRAGANA LETTER DO
89 0x3042, // 0x306a HIRAGANA LETTER NA
90 0x3044, // 0x306b HIRAGANA LETTER NI
91 0x3046, // 0x306c HIRAGANA LETTER NU
92 0x3048, // 0x306d HIRAGANA LETTER NE
93 0x304a, // 0x306e HIRAGANA LETTER NO
94 0x3042, // 0x306f HIRAGANA LETTER HA
95 0x3042, // 0x3070 HIRAGANA LETTER BA
96 0x3042, // 0x3071 HIRAGANA LETTER PA
97 0x3044, // 0x3072 HIRAGANA LETTER HI
98 0x3044, // 0x3073 HIRAGANA LETTER BI
99 0x3044, // 0x3074 HIRAGANA LETTER PI
100 0x3046, // 0x3075 HIRAGANA LETTER HU
101 0x3046, // 0x3076 HIRAGANA LETTER BU
102 0x3046, // 0x3077 HIRAGANA LETTER PU
103 0x3048, // 0x3078 HIRAGANA LETTER HE
104 0x3048, // 0x3079 HIRAGANA LETTER BE
105 0x3048, // 0x307a HIRAGANA LETTER PE
106 0x304a, // 0x307b HIRAGANA LETTER HO
107 0x304a, // 0x307c HIRAGANA LETTER BO
108 0x304a, // 0x307d HIRAGANA LETTER PO
109 0x3042, // 0x307e HIRAGANA LETTER MA
110 0x3044, // 0x307f HIRAGANA LETTER MI
111 0x3046, // 0x3080 HIRAGANA LETTER MU
112 0x3048, // 0x3081 HIRAGANA LETTER ME
113 0x304a, // 0x3082 HIRAGANA LETTER MO
114 0x3041, // 0x3083 HIRAGANA LETTER SMALL YA
115 0x3042, // 0x3084 HIRAGANA LETTER YA
116 0x3045, // 0x3085 HIRAGANA LETTER SMALL YU
117 0x3046, // 0x3086 HIRAGANA LETTER YU
118 0x3049, // 0x3087 HIRAGANA LETTER SMALL YO
119 0x304a, // 0x3088 HIRAGANA LETTER YO
120 0x3042, // 0x3089 HIRAGANA LETTER RA
121 0x3044, // 0x308a HIRAGANA LETTER RI
122 0x3046, // 0x308b HIRAGANA LETTER RU
123 0x3048, // 0x308c HIRAGANA LETTER RE
124 0x304a, // 0x308d HIRAGANA LETTER RO
125 0x3041, // 0x308e HIRAGANA LETTER SMALL WA
126 0x3042, // 0x308f HIRAGANA LETTER WA
127 0x3044, // 0x3090 HIRAGANA LETTER WI
128 0x3048, // 0x3091 HIRAGANA LETTER WE
129 0x304a, // 0x3092 HIRAGANA LETTER WO
130 0x0000, // 0x3093 HIRAGANA LETTER N
131 0x3046, // 0x3094 HIRAGANA LETTER VU
132 0x0000, // 0x3095
133 0x0000, // 0x3096
134 0x0000, // 0x3097
135 0x0000, // 0x3098
136 0x0000, // 0x3099 COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
137 0x0000, // 0x309a COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
138 0x0000, // 0x309b KATAKANA-HIRAGANA VOICED SOUND MARK
139 0x0000, // 0x309c KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
140 0x0000, // 0x309d HIRAGANA ITERATION MARK
141 0x0000, // 0x309e HIRAGANA VOICED ITERATION MARK
142 0x0000, // 0x309f
143 0x0000, // 0x30a0
144 0x30a1, // 0x30a1 KATAKANA LETTER SMALL A
145 0x30a2, // 0x30a2 KATAKANA LETTER A
146 0x30a3, // 0x30a3 KATAKANA LETTER SMALL I
147 0x30a4, // 0x30a4 KATAKANA LETTER I
148 0x30a5, // 0x30a5 KATAKANA LETTER SMALL U
149 0x30a6, // 0x30a6 KATAKANA LETTER U
150 0x30a7, // 0x30a7 KATAKANA LETTER SMALL E
151 0x30a8, // 0x30a8 KATAKANA LETTER E
152 0x30a9, // 0x30a9 KATAKANA LETTER SMALL O
153 0x30aa, // 0x30aa KATAKANA LETTER O
154 0x30a2, // 0x30ab KATAKANA LETTER KA
155 0x30a2, // 0x30ac KATAKANA LETTER GA
156 0x30a4, // 0x30ad KATAKANA LETTER KI
157 0x30a4, // 0x30ae KATAKANA LETTER GI
158 0x30a6, // 0x30af KATAKANA LETTER KU
159 0x30a6, // 0x30b0 KATAKANA LETTER GU
160 0x30a8, // 0x30b1 KATAKANA LETTER KE
161 0x30a8, // 0x30b2 KATAKANA LETTER GE
162 0x30aa, // 0x30b3 KATAKANA LETTER KO
163 0x30aa, // 0x30b4 KATAKANA LETTER GO
164 0x30a2, // 0x30b5 KATAKANA LETTER SA
165 0x30a2, // 0x30b6 KATAKANA LETTER ZA
166 0x30a4, // 0x30b7 KATAKANA LETTER SI
167 0x30a4, // 0x30b8 KATAKANA LETTER ZI
168 0x30a6, // 0x30b9 KATAKANA LETTER SU
169 0x30a6, // 0x30ba KATAKANA LETTER ZU
170 0x30a8, // 0x30bb KATAKANA LETTER SE
171 0x30a8, // 0x30bc KATAKANA LETTER ZE
172 0x30aa, // 0x30bd KATAKANA LETTER SO
173 0x30aa, // 0x30be KATAKANA LETTER ZO
174 0x30a2, // 0x30bf KATAKANA LETTER TA
175 0x30a2, // 0x30c0 KATAKANA LETTER DA
176 0x30a4, // 0x30c1 KATAKANA LETTER TI
177 0x30a4, // 0x30c2 KATAKANA LETTER DI
178 0x30a5, // 0x30c3 KATAKANA LETTER SMALL TU
179 0x30a6, // 0x30c4 KATAKANA LETTER TU
180 0x30a6, // 0x30c5 KATAKANA LETTER DU
181 0x30a8, // 0x30c6 KATAKANA LETTER TE
182 0x30a8, // 0x30c7 KATAKANA LETTER DE
183 0x30aa, // 0x30c8 KATAKANA LETTER TO
184 0x30aa, // 0x30c9 KATAKANA LETTER DO
185 0x30a2, // 0x30ca KATAKANA LETTER NA
186 0x30a4, // 0x30cb KATAKANA LETTER NI
187 0x30a6, // 0x30cc KATAKANA LETTER NU
188 0x30a8, // 0x30cd KATAKANA LETTER NE
189 0x30aa, // 0x30ce KATAKANA LETTER NO
190 0x30a2, // 0x30cf KATAKANA LETTER HA
191 0x30a2, // 0x30d0 KATAKANA LETTER BA
192 0x30a2, // 0x30d1 KATAKANA LETTER PA
193 0x30a4, // 0x30d2 KATAKANA LETTER HI
194 0x30a4, // 0x30d3 KATAKANA LETTER BI
195 0x30a4, // 0x30d4 KATAKANA LETTER PI
196 0x30a6, // 0x30d5 KATAKANA LETTER HU
197 0x30a6, // 0x30d6 KATAKANA LETTER BU
198 0x30a6, // 0x30d7 KATAKANA LETTER PU
199 0x30a8, // 0x30d8 KATAKANA LETTER HE
200 0x30a8, // 0x30d9 KATAKANA LETTER BE
201 0x30a8, // 0x30da KATAKANA LETTER PE
202 0x30aa, // 0x30db KATAKANA LETTER HO
203 0x30aa, // 0x30dc KATAKANA LETTER BO
204 0x30aa, // 0x30dd KATAKANA LETTER PO
205 0x30a2, // 0x30de KATAKANA LETTER MA
206 0x30a4, // 0x30df KATAKANA LETTER MI
207 0x30a6, // 0x30e0 KATAKANA LETTER MU
208 0x30a8, // 0x30e1 KATAKANA LETTER ME
209 0x30aa, // 0x30e2 KATAKANA LETTER MO
210 0x30a1, // 0x30e3 KATAKANA LETTER SMALL YA
211 0x30a2, // 0x30e4 KATAKANA LETTER YA
212 0x30a5, // 0x30e5 KATAKANA LETTER SMALL YU
213 0x30a6, // 0x30e6 KATAKANA LETTER YU
214 0x30a9, // 0x30e7 KATAKANA LETTER SMALL YO
215 0x30aa, // 0x30e8 KATAKANA LETTER YO
216 0x30a2, // 0x30e9 KATAKANA LETTER RA
217 0x30a4, // 0x30ea KATAKANA LETTER RI
218 0x30a6, // 0x30eb KATAKANA LETTER RU
219 0x30a8, // 0x30ec KATAKANA LETTER RE
220 0x30aa, // 0x30ed KATAKANA LETTER RO
221 0x30a1, // 0x30ee KATAKANA LETTER SMALL WA
222 0x30a2, // 0x30ef KATAKANA LETTER WA
223 0x30a4, // 0x30f0 KATAKANA LETTER WI
224 0x30a8, // 0x30f1 KATAKANA LETTER WE
225 0x30aa, // 0x30f2 KATAKANA LETTER WO
226 0x0000, // 0x30f3 KATAKANA LETTER N
227 0x30a6, // 0x30f4 KATAKANA LETTER VU
228 0x30a1, // 0x30f5 KATAKANA LETTER SMALL KA
229 0x30a7, // 0x30f6 KATAKANA LETTER SMALL KE
230 0x30a2, // 0x30f7 KATAKANA LETTER VA
231 0x30a4, // 0x30f8 KATAKANA LETTER VI
232 0x30a8, // 0x30f9 KATAKANA LETTER VE
233 0x30aa // 0x30fa KATAKANA LETTER VO
234 // 0x0000, // 0x30fb KATAKANA MIDDLE DOT
235 // 0x0000, // 0x30fc KATAKANA-HIRAGANA PROLONGED SOUND MARK
236 // 0x0000, // 0x30fd KATAKANA ITERATION MARK
237 // 0x0000, // 0x30fe KATAKANA VOICED ITERATION MARK
238 // 0x0000 // 0x30ff
241 static sal_Unicode table_halfwidth[] = {
242 // 0x0000, // 0xff61 HALFWIDTH IDEOGRAPHIC FULL STOP
243 // 0x0000, // 0xff62 HALFWIDTH LEFT CORNER BRACKET
244 // 0x0000, // 0xff63 HALFWIDTH RIGHT CORNER BRACKET
245 // 0x0000, // 0xff64 HALFWIDTH IDEOGRAPHIC COMMA
246 // 0x0000, // 0xff65 HALFWIDTH KATAKANA MIDDLE DOT
247 0xff75, // 0xff66 HALFWIDTH KATAKANA LETTER WO
248 0xff67, // 0xff67 HALFWIDTH KATAKANA LETTER SMALL A
249 0xff68, // 0xff68 HALFWIDTH KATAKANA LETTER SMALL I
250 0xff69, // 0xff69 HALFWIDTH KATAKANA LETTER SMALL U
251 0xff6a, // 0xff6a HALFWIDTH KATAKANA LETTER SMALL E
252 0xff6b, // 0xff6b HALFWIDTH KATAKANA LETTER SMALL O
253 0xff67, // 0xff6c HALFWIDTH KATAKANA LETTER SMALL YA
254 0xff69, // 0xff6d HALFWIDTH KATAKANA LETTER SMALL YU
255 0xff6b, // 0xff6e HALFWIDTH KATAKANA LETTER SMALL YO
256 0xff69, // 0xff6f HALFWIDTH KATAKANA LETTER SMALL TU
257 0x0000, // 0xff70 HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK
258 0xff71, // 0xff71 HALFWIDTH KATAKANA LETTER A
259 0xff72, // 0xff72 HALFWIDTH KATAKANA LETTER I
260 0xff73, // 0xff73 HALFWIDTH KATAKANA LETTER U
261 0xff74, // 0xff74 HALFWIDTH KATAKANA LETTER E
262 0xff75, // 0xff75 HALFWIDTH KATAKANA LETTER O
263 0xff71, // 0xff76 HALFWIDTH KATAKANA LETTER KA
264 0xff72, // 0xff77 HALFWIDTH KATAKANA LETTER KI
265 0xff73, // 0xff78 HALFWIDTH KATAKANA LETTER KU
266 0xff74, // 0xff79 HALFWIDTH KATAKANA LETTER KE
267 0xff75, // 0xff7a HALFWIDTH KATAKANA LETTER KO
268 0xff71, // 0xff7b HALFWIDTH KATAKANA LETTER SA
269 0xff72, // 0xff7c HALFWIDTH KATAKANA LETTER SI
270 0xff73, // 0xff7d HALFWIDTH KATAKANA LETTER SU
271 0xff74, // 0xff7e HALFWIDTH KATAKANA LETTER SE
272 0xff75, // 0xff7f HALFWIDTH KATAKANA LETTER SO
273 0xff71, // 0xff80 HALFWIDTH KATAKANA LETTER TA
274 0xff72, // 0xff81 HALFWIDTH KATAKANA LETTER TI
275 0xff73, // 0xff82 HALFWIDTH KATAKANA LETTER TU
276 0xff74, // 0xff83 HALFWIDTH KATAKANA LETTER TE
277 0xff75, // 0xff84 HALFWIDTH KATAKANA LETTER TO
278 0xff71, // 0xff85 HALFWIDTH KATAKANA LETTER NA
279 0xff72, // 0xff86 HALFWIDTH KATAKANA LETTER NI
280 0xff73, // 0xff87 HALFWIDTH KATAKANA LETTER NU
281 0xff74, // 0xff88 HALFWIDTH KATAKANA LETTER NE
282 0xff75, // 0xff89 HALFWIDTH KATAKANA LETTER NO
283 0xff71, // 0xff8a HALFWIDTH KATAKANA LETTER HA
284 0xff72, // 0xff8b HALFWIDTH KATAKANA LETTER HI
285 0xff73, // 0xff8c HALFWIDTH KATAKANA LETTER HU
286 0xff74, // 0xff8d HALFWIDTH KATAKANA LETTER HE
287 0xff75, // 0xff8e HALFWIDTH KATAKANA LETTER HO
288 0xff71, // 0xff8f HALFWIDTH KATAKANA LETTER MA
289 0xff72, // 0xff90 HALFWIDTH KATAKANA LETTER MI
290 0xff73, // 0xff91 HALFWIDTH KATAKANA LETTER MU
291 0xff74, // 0xff92 HALFWIDTH KATAKANA LETTER ME
292 0xff75, // 0xff93 HALFWIDTH KATAKANA LETTER MO
293 0xff71, // 0xff94 HALFWIDTH KATAKANA LETTER YA
294 0xff73, // 0xff95 HALFWIDTH KATAKANA LETTER YU
295 0xff75, // 0xff96 HALFWIDTH KATAKANA LETTER YO
296 0xff71, // 0xff97 HALFWIDTH KATAKANA LETTER RA
297 0xff72, // 0xff98 HALFWIDTH KATAKANA LETTER RI
298 0xff73, // 0xff99 HALFWIDTH KATAKANA LETTER RU
299 0xff74, // 0xff9a HALFWIDTH KATAKANA LETTER RE
300 0xff75, // 0xff9b HALFWIDTH KATAKANA LETTER RO
301 0xff71 // 0xff9c HALFWIDTH KATAKANA LETTER WA
302 // 0x0000, // 0xff9d HALFWIDTH KATAKANA LETTER N
303 // 0x0000, // 0xff9e HALFWIDTH KATAKANA VOICED SOUND MARK
304 // 0x0000 // 0xff9f HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
308 OUString SAL_CALL
309 ignoreProlongedSoundMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
310 throw(RuntimeException)
312 // Create a string buffer which can hold nCount + 1 characters.
313 // The reference count is 0 now.
314 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
315 sal_Unicode * dst = newStr->buffer;
316 const sal_Unicode * src = inStr.getStr() + startPos;
318 sal_Int32 *p = 0;
319 sal_Int32 position = 0;
321 if (useOffset) {
322 // Allocate nCount length to offset argument.
323 offset.realloc( nCount );
324 p = offset.getArray();
325 position = startPos;
329 sal_Unicode previousChar = *src ++;
330 sal_Unicode currentChar;
332 // Conversion
333 while (-- nCount > 0) {
334 currentChar = *src ++;
336 if (currentChar == 0x30fc || // KATAKANA-HIRAGANA PROLONGED SOUND MARK
337 currentChar == 0xff70) { // HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK
339 if (0x3041 <= previousChar && previousChar <= 0x30fa) {
340 currentChar = table_normalwidth[ previousChar - 0x3041 ];
342 else if (0xff66 <= previousChar && previousChar <= 0xff9c) {
343 currentChar = table_halfwidth[ previousChar - 0xff66 ];
347 if (useOffset)
348 *p ++ = position ++;
349 *dst ++ = previousChar;
350 previousChar = currentChar;
353 if (nCount == 0) {
354 if (useOffset)
355 *p = position;
356 *dst ++ = previousChar;
359 *dst = (sal_Unicode) 0;
361 newStr->length = sal_Int32(dst - newStr->buffer);
362 if (useOffset)
363 offset.realloc(newStr->length);
364 return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
368 } } } }