LibreOffice Module i18npool (master) 1
ignoreIandEfollowedByYa_ja_JP.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21
23
24#include <numeric>
25
26using namespace com::sun::star::uno;
27using namespace com::sun::star::lang;
28
29namespace i18npool {
30
32 { 0x30A3, 0x0000 }, // KATAKANA LETTER SMALL I
33 { 0x30A4, 0x0000 }, // KATAKANA LETTER I
34 { 0x30A7, 0x0000 }, // KATAKANA LETTER SMALL E
35 { 0x30A8, 0x0000 }, // KATAKANA LETTER E
36 { 0x30AD, 0x0000 }, // KATAKANA LETTER KI
37 { 0x30AE, 0x0000 }, // KATAKANA LETTER GI
38 { 0x30B1, 0x0000 }, // KATAKANA LETTER KE
39 { 0x30B2, 0x0000 }, // KATAKANA LETTER GE
40 { 0x30B7, 0x0000 }, // KATAKANA LETTER SI
41 { 0x30B8, 0x0000 }, // KATAKANA LETTER ZI
42 { 0x30BB, 0x0000 }, // KATAKANA LETTER SE
43 { 0x30BC, 0x0000 }, // KATAKANA LETTER ZE
44 { 0x30C1, 0x0000 }, // KATAKANA LETTER TI
45 { 0x30C2, 0x0000 }, // KATAKANA LETTER DI
46 { 0x30C6, 0x0000 }, // KATAKANA LETTER TE
47 { 0x30C7, 0x0000 }, // KATAKANA LETTER DE
48 { 0x30CB, 0x0000 }, // KATAKANA LETTER NI
49 { 0x30CD, 0x0000 }, // KATAKANA LETTER NE
50 { 0x30D2, 0x0000 }, // KATAKANA LETTER HI
51 { 0x30D3, 0x0000 }, // KATAKANA LETTER BI
52 { 0x30D4, 0x0000 }, // KATAKANA LETTER PI
53 { 0x30D8, 0x0000 }, // KATAKANA LETTER HE
54 { 0x30D9, 0x0000 }, // KATAKANA LETTER BE
55 { 0x30DA, 0x0000 }, // KATAKANA LETTER PE
56 { 0x30DF, 0x0000 }, // KATAKANA LETTER MI
57 { 0x30E1, 0x0000 }, // KATAKANA LETTER ME
58 { 0x30EA, 0x0000 }, // KATAKANA LETTER RI
59 { 0x30EC, 0x0000 }, // KATAKANA LETTER RE
60 { 0x30F0, 0x0000 }, // KATAKANA LETTER WI
61 { 0x30F1, 0x0000 }, // KATAKANA LETTER WE
62 { 0x30F6, 0x0000 }, // KATAKANA LETTER SMALL KE
63 { 0x30F8, 0x0000 }, // KATAKANA LETTER VI
64 { 0x30F9, 0x0000 } // KATAKANA LETTER VE
65};
66
67
68OUString
69ignoreIandEfollowedByYa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
70{
71 // Create a string buffer which can hold nCount + 1 characters.
72 // The reference count is 1 now.
73 rtl_uString * newStr = rtl_uString_alloc(nCount);
74 sal_Unicode * dst = newStr->buffer;
75 const sal_Unicode * src = inStr.getStr() + startPos;
76
77 if (pOffset) {
78 // Allocate nCount length to offset argument.
79 pOffset->realloc( nCount );
80 auto [begin, end] = asNonConstRange(*pOffset);
81 std::iota(begin, end, startPos);
82 }
83
84
85 sal_Unicode previousChar = *src ++;
86 sal_Unicode currentChar;
87
88 // One to one mapping
89 i18nutil::oneToOneMapping aTable(IandE, sizeof(IandE));
90
91 // Translation
92 while (-- nCount > 0) {
93 currentChar = *src ++;
94
95 // the character listed in above table + YA --> the character + A
96 if (currentChar == 0x30E3 || // KATAKANA LETTER SMALL YA
97 currentChar == 0x30E4) { // KATAKANA LETTER YA
98 if (aTable[ previousChar ] != previousChar) {
99 *dst ++ = previousChar;
100 *dst ++ = 0x30A2; // KATAKANA LETTER A
101 previousChar = *src ++;
102 nCount --;
103 continue;
104 }
105 }
106
107 *dst ++ = previousChar;
108 previousChar = currentChar;
109 }
110
111 if (nCount == 0) {
112 *dst ++ = previousChar;
113 }
114
115 *dst = u'\0';
116
117 newStr->length = sal_Int32(dst - newStr->buffer);
118 if (pOffset)
119 pOffset->realloc(newStr->length);
120 return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
121}
122
123}
124
125/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int nCount
float u
Constant values shared between i18npool and, for example, the number formatter.
i18nutil::OneToOneMappingTable_t const IandE[]
enumrange< T >::Iterator begin(enumrange< T >)
end
sal_uInt16 sal_Unicode