1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <transliteration_Ignore.hxx>
22 using namespace com::sun::star::uno
;
23 using namespace com::sun::star::lang
;
28 ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
, bool useOffset
)
30 // Create a string buffer which can hold nCount + 1 characters.
31 // The reference count is 1 now.
32 rtl_uString
* newStr
= rtl_uString_alloc(nCount
);
33 sal_Unicode
* dst
= newStr
->buffer
;
34 const sal_Unicode
* src
= inStr
.getStr() + startPos
;
36 sal_Int32
*p
= nullptr;
37 sal_Int32 position
= 0;
39 // Allocate nCount length to offset argument.
40 offset
.realloc( nCount
);
41 p
= offset
.getArray();
46 sal_Unicode previousChar
= *src
++;
47 sal_Unicode currentChar
;
50 while (-- nCount
> 0) {
51 currentChar
= *src
++;
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
61 *dst
++ = 0x30AD; // KATAKANA LETTER KI
62 *dst
++ = currentChar
;
63 previousChar
= *src
++;
71 *dst
++ = previousChar
;
72 previousChar
= currentChar
;
78 *dst
++ = previousChar
;
83 newStr
->length
= sal_Int32(dst
- newStr
->buffer
);
85 offset
.realloc(newStr
->length
);
86 return OUString(newStr
, SAL_NO_ACQUIRE
); // take ownership
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */