LibreOffice Module i18npool (master) 1
ignoreKiKuFollowedBySa_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
22#include <numeric>
23
24using namespace com::sun::star::uno;
25using namespace com::sun::star::lang;
26
27namespace i18npool {
28
29OUString
30ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
31{
32 // Create a string buffer which can hold nCount + 1 characters.
33 // The reference count is 1 now.
34 rtl_uString * newStr = rtl_uString_alloc(nCount);
35 sal_Unicode * dst = newStr->buffer;
36 const sal_Unicode * src = inStr.getStr() + startPos;
37
38 if (pOffset) {
39 // Allocate nCount length to offset argument.
40 pOffset->realloc( nCount );
41 auto [begin, end] = asNonConstRange(*pOffset);
42 std::iota(begin, end, startPos);
43 }
44
45
46 sal_Unicode previousChar = *src ++;
47 sal_Unicode currentChar;
48
49 // Translation
50 while (-- nCount > 0) {
51 currentChar = *src ++;
52
53 // KU + Sa-So --> KI + Sa-So
54 if (previousChar == 0x30AF ) { // KATAKANA LETTER KU
55 if (0x30B5 <= currentChar && // KATAKANA LETTER SA
56 currentChar <= 0x30BE) { // KATAKANA LETTER ZO
57 *dst ++ = 0x30AD; // KATAKANA LETTER KI
58 *dst ++ = currentChar;
59 previousChar = *src ++;
60 nCount --;
61 continue;
62 }
63 }
64
65 *dst ++ = previousChar;
66 previousChar = currentChar;
67 }
68
69 if (nCount == 0) {
70 *dst ++ = previousChar;
71 }
72
73 *dst = u'\0';
74
75 newStr->length = sal_Int32(dst - newStr->buffer);
76 if (pOffset)
77 pOffset->realloc(newStr->length);
78 return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
79}
80
81}
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
int nCount
float u
Constant values shared between i18npool and, for example, the number formatter.
enumrange< T >::Iterator begin(enumrange< T >)
end
sal_uInt16 sal_Unicode