0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A *
0N/A */
0N/A
0N/A/*
0N/A *
3171N/A * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
0N/A *
0N/A * This file is a modification of the ICU file IndicReordering.cpp
0N/A * by Jens Herden and Javier Sola for Khmer language
0N/A *
0N/A */
0N/A
0N/A#include "LETypes.h"
0N/A#include "OpenTypeTables.h"
0N/A#include "KhmerReordering.h"
0N/A#include "LEGlyphStorage.h"
0N/A
1693N/A
1693N/AU_NAMESPACE_BEGIN
1693N/A
0N/A// Characters that get refered to by name...
0N/Aenum
0N/A{
0N/A C_SIGN_ZWNJ = 0x200C,
0N/A C_SIGN_ZWJ = 0x200D,
0N/A C_DOTTED_CIRCLE = 0x25CC,
0N/A C_RO = 0x179A,
0N/A C_VOWEL_AA = 0x17B6,
0N/A C_SIGN_NIKAHIT = 0x17C6,
0N/A C_VOWEL_E = 0x17C1,
0N/A C_COENG = 0x17D2
0N/A};
0N/A
0N/A
0N/Aenum
0N/A{
1693N/A // simple classes, they are used in the statetable (in this file) to control the length of a syllable
1693N/A // they are also used to know where a character should be placed (location in reference to the base character)
1693N/A // and also to know if a character, when independtly displayed, should be displayed with a dotted-circle to
1693N/A // indicate error in syllable construction
0N/A _xx = KhmerClassTable::CC_RESERVED,
1693N/A _sa = KhmerClassTable::CC_SIGN_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_POS_ABOVE,
1693N/A _sp = KhmerClassTable::CC_SIGN_AFTER | KhmerClassTable::CF_DOTTED_CIRCLE| KhmerClassTable::CF_POS_AFTER,
0N/A _c1 = KhmerClassTable::CC_CONSONANT | KhmerClassTable::CF_CONSONANT,
0N/A _c2 = KhmerClassTable::CC_CONSONANT2 | KhmerClassTable::CF_CONSONANT,
0N/A _c3 = KhmerClassTable::CC_CONSONANT3 | KhmerClassTable::CF_CONSONANT,
1693N/A _rb = KhmerClassTable::CC_ROBAT | KhmerClassTable::CF_POS_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE,
1693N/A _cs = KhmerClassTable::CC_CONSONANT_SHIFTER | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_SHIFTER,
1693N/A _dl = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BEFORE | KhmerClassTable::CF_DOTTED_CIRCLE,
1693N/A _db = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BELOW | KhmerClassTable::CF_DOTTED_CIRCLE,
1693N/A _da = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_ABOVE_VOWEL,
1693N/A _dr = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_AFTER | KhmerClassTable::CF_DOTTED_CIRCLE,
1693N/A _co = KhmerClassTable::CC_COENG | KhmerClassTable::CF_COENG | KhmerClassTable::CF_DOTTED_CIRCLE,
0N/A
0N/A // split vowel
0N/A _va = _da | KhmerClassTable::CF_SPLIT_VOWEL,
0N/A _vr = _dr | KhmerClassTable::CF_SPLIT_VOWEL
0N/A};
0N/A
0N/A
0N/A// Character class tables
1693N/A// _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs...
0N/A// _sa Sign placed above the base
0N/A// _sp Sign placed after the base
1693N/A// _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants)
0N/A// _c2 Consonant of type 2 (only RO)
0N/A// _c3 Consonant of type 3
0N/A// _rb Khmer sign robat u17CC. combining mark for subscript consonants
0N/A// _cd Consonant-shifter
0N/A// _dl Dependent vowel placed before the base (left of the base)
0N/A// _db Dependent vowel placed below the base
0N/A// _da Dependent vowel placed above the base
0N/A// _dr Dependent vowel placed behind the base (right of the base)
1693N/A// _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following
1693N/A// it to create a subscript consonant or independent vowel
1693N/A// _va Khmer split vowel in wich the first part is before the base and the second one above the base
1693N/A// _vr Khmer split vowel in wich the first part is before the base and the second one behind (right of) the base
0N/A
0N/Astatic const KhmerClassTable::CharClass khmerCharClasses[] =
0N/A{
0N/A _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, // 1780 - 178F
0N/A _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c2, _c1, _c1, _c1, _c3, _c3, // 1790 - 179F
0N/A _c1, _c3, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, // 17A0 - 17AF
0N/A _c1, _c1, _c1, _c1, _dr, _dr, _dr, _da, _da, _da, _da, _db, _db, _db, _va, _vr, // 17B0 - 17BF
0N/A _vr, _dl, _dl, _dl, _vr, _vr, _sa, _sp, _sp, _cs, _cs, _sa, _rb, _sa, _sa, _sa, // 17C0 - 17CF
0N/A _sa, _sa, _co, _sa, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _sa, _xx, _xx, // 17D0 - 17DF
0N/A};
0N/A
0N/A
0N/A//
0N/A// Khmer Class Tables
0N/A//
0N/A
0N/A//
1693N/A// The range of characters defined in the above table is defined here. FOr Khmer 1780 to 17DF
1693N/A// Even if the Khmer range is bigger, all other characters are not combinable, and therefore treated
1693N/A// as _xx
0N/Astatic const KhmerClassTable khmerClassTable = {0x1780, 0x17df, khmerCharClasses};
0N/A
0N/A
1693N/A// Below we define how a character in the input string is either in the khmerCharClasses table
1693N/A// (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear
1693N/A// within the syllable, but are not in the table) we also get their type back, or an unknown object
1693N/A// in which case we get _xx (CC_RESERVED) back
0N/AKhmerClassTable::CharClass KhmerClassTable::getCharClass(LEUnicode ch) const
0N/A{
1693N/A
0N/A if (ch == C_SIGN_ZWJ) {
0N/A return CC_ZERO_WIDTH_J_MARK;
0N/A }
0N/A
0N/A if (ch == C_SIGN_ZWNJ) {
0N/A return CC_ZERO_WIDTH_NJ_MARK;
0N/A }
0N/A
0N/A if (ch < firstChar || ch > lastChar) {
0N/A return CC_RESERVED;
0N/A }
0N/A
0N/A return classTable[ch - firstChar];
0N/A}
0N/A
0N/Aconst KhmerClassTable *KhmerClassTable::getKhmerClassTable()
0N/A{
0N/A return &khmerClassTable;
0N/A}
0N/A
0N/A
0N/A
3171N/Aclass KhmerReorderingOutput : public UMemory {
0N/Aprivate:
3171N/A le_int32 fSyllableCount;
0N/A le_int32 fOutIndex;
0N/A LEUnicode *fOutChars;
0N/A
0N/A LEGlyphStorage &fGlyphStorage;
0N/A
1693N/A
0N/Apublic:
3171N/A KhmerReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage)
3171N/A : fSyllableCount(0), fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage)
0N/A {
0N/A // nothing else to do...
0N/A }
0N/A
3171N/A ~KhmerReorderingOutput()
0N/A {
0N/A // nothing to do here...
0N/A }
0N/A
3171N/A void reset()
3171N/A {
3171N/A fSyllableCount += 1;
3171N/A }
3171N/A
0N/A void writeChar(LEUnicode ch, le_uint32 charIndex, FeatureMask charFeatures)
0N/A {
0N/A LEErrorCode success = LE_NO_ERROR;
0N/A
0N/A fOutChars[fOutIndex] = ch;
0N/A
0N/A fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
3171N/A fGlyphStorage.setAuxData(fOutIndex, charFeatures | (fSyllableCount & LE_GLYPH_GROUP_MASK), success);
0N/A
0N/A fOutIndex += 1;
0N/A }
0N/A
0N/A le_int32 getOutputIndex()
0N/A {
0N/A return fOutIndex;
0N/A }
0N/A};
0N/A
0N/A
0N/A#define blwfFeatureTag LE_BLWF_FEATURE_TAG
0N/A#define pstfFeatureTag LE_PSTF_FEATURE_TAG
0N/A#define presFeatureTag LE_PRES_FEATURE_TAG
0N/A#define blwsFeatureTag LE_BLWS_FEATURE_TAG
0N/A#define abvsFeatureTag LE_ABVS_FEATURE_TAG
0N/A#define pstsFeatureTag LE_PSTS_FEATURE_TAG
0N/A
0N/A#define blwmFeatureTag LE_BLWM_FEATURE_TAG
0N/A#define abvmFeatureTag LE_ABVM_FEATURE_TAG
0N/A#define distFeatureTag LE_DIST_FEATURE_TAG
0N/A
0N/A#define prefFeatureTag LE_PREF_FEATURE_TAG
0N/A#define abvfFeatureTag LE_ABVF_FEATURE_TAG
0N/A#define cligFeatureTag LE_CLIG_FEATURE_TAG
0N/A#define mkmkFeatureTag LE_MKMK_FEATURE_TAG
0N/A
0N/A#define prefFeatureMask 0x80000000UL
0N/A#define blwfFeatureMask 0x40000000UL
0N/A#define abvfFeatureMask 0x20000000UL
0N/A#define pstfFeatureMask 0x10000000UL
0N/A#define presFeatureMask 0x08000000UL
0N/A#define blwsFeatureMask 0x04000000UL
0N/A#define abvsFeatureMask 0x02000000UL
0N/A#define pstsFeatureMask 0x01000000UL
0N/A#define cligFeatureMask 0x00800000UL
0N/A#define distFeatureMask 0x00400000UL
0N/A#define blwmFeatureMask 0x00200000UL
0N/A#define abvmFeatureMask 0x00100000UL
0N/A#define mkmkFeatureMask 0x00080000UL
0N/A
1693N/A#define tagPref (prefFeatureMask | presFeatureMask | cligFeatureMask | distFeatureMask)
1693N/A#define tagAbvf (abvfFeatureMask | abvsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | mkmkFeatureMask)
1693N/A#define tagPstf (blwfFeatureMask | blwsFeatureMask | prefFeatureMask | presFeatureMask | pstfFeatureMask | pstsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask)
1693N/A#define tagBlwf (blwfFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask | mkmkFeatureMask)
1693N/A#define tagDefault (prefFeatureMask | blwfFeatureMask | presFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask | mkmkFeatureMask)
0N/A
0N/A
0N/A
0N/A// These are in the order in which the features need to be applied
0N/A// for correct processing
0N/Astatic const FeatureMap featureMap[] =
0N/A{
0N/A // Shaping features
0N/A {prefFeatureTag, prefFeatureMask},
0N/A {blwfFeatureTag, blwfFeatureMask},
0N/A {abvfFeatureTag, abvfFeatureMask},
0N/A {pstfFeatureTag, pstfFeatureMask},
0N/A {presFeatureTag, presFeatureMask},
0N/A {blwsFeatureTag, blwsFeatureMask},
0N/A {abvsFeatureTag, abvsFeatureMask},
0N/A {pstsFeatureTag, pstsFeatureMask},
0N/A {cligFeatureTag, cligFeatureMask},
0N/A
0N/A // Positioning features
0N/A {distFeatureTag, distFeatureMask},
0N/A {blwmFeatureTag, blwmFeatureMask},
0N/A {abvmFeatureTag, abvmFeatureMask},
0N/A {mkmkFeatureTag, mkmkFeatureMask},
0N/A};
0N/A
0N/Astatic const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
0N/A
0N/A// The stateTable is used to calculate the end (the length) of a well
0N/A// formed Khmer Syllable.
0N/A//
1693N/A// Each horizontal line is ordered exactly the same way as the values in KhmerClassTable
1693N/A// CharClassValues in KhmerReordering.h This coincidence of values allows the
1693N/A// follow up of the table.
0N/A//
1693N/A// Each line corresponds to a state, which does not necessarily need to be a type
1693N/A// of component... for example, state 2 is a base, with is always a first character
1693N/A// in the syllable, but the state could be produced a consonant of any type when
1693N/A// it is the first character that is analysed (in ground state).
0N/A//
0N/A// Differentiating 3 types of consonants is necessary in order to
0N/A// forbid the use of certain combinations, such as having a second
1693N/A// coeng after a coeng RO,
1693N/A// The inexistent possibility of having a type 3 after another type 3 is permitted,
1693N/A// eliminating it would very much complicate the table, and it does not create typing
1693N/A// problems, as the case above.
0N/A//
1693N/A// The table is quite complex, in order to limit the number of coeng consonants
1693N/A// to 2 (by means of the table).
0N/A//
0N/A// There a peculiarity, as far as Unicode is concerned:
0N/A// - The consonant-shifter is considered in two possible different
1693N/A// locations, the one considered in Unicode 3.0 and the one considered in
1693N/A// Unicode 4.0. (there is a backwards compatibility problem in this standard).
0N/A
0N/A
1693N/A// xx independent character, such as a number, punctuation sign or non-khmer char
0N/A//
0N/A// c1 Khmer consonant of type 1 or an independent vowel
0N/A// that is, a letter in which the subscript for is only under the
0N/A// base, not taking any space to the right or to the left
0N/A//
0N/A// c2 Khmer consonant of type 2, the coeng form takes space under
0N/A// and to the left of the base (only RO is of this type)
0N/A//
0N/A// c3 Khmer consonant of type 3. Its subscript form takes space under
0N/A// and to the right of the base.
0N/A//
0N/A// cs Khmer consonant shifter
0N/A//
0N/A// rb Khmer robat
0N/A//
0N/A// co coeng character (u17D2)
0N/A//
1693N/A// dv dependent vowel (including split vowels, they are treated in the same way).
1693N/A// even if dv is not defined above, the component that is really tested for is
1693N/A// KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels
0N/A//
0N/A// zwj Zero Width joiner
0N/A//
0N/A// zwnj Zero width non joiner
0N/A//
0N/A// sa above sign
0N/A//
0N/A// sp post sign
0N/A//
0N/A// there are lines with equal content but for an easier understanding
0N/A// (and maybe change in the future) we did not join them
0N/A//
0N/Astatic const le_int8 khmerStateTable[][KhmerClassTable::CC_COUNT] =
0N/A{
0N/A
0N/A// xx c1 c2 c3 zwnj cs rb co dv sa sp zwj
0N/A { 1, 2, 2, 2, 1, 1, 1, 6, 1, 1, 1, 2}, // 0 - ground state
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1 - exit state (or sign to the right of the syllable)
0N/A {-1, -1, -1, -1, 3, 4, 5, 6, 16, 17, 1, -1}, // 2 - Base consonant
0N/A {-1, -1, -1, -1, -1, 4, -1, -1, 16, -1, -1, -1}, // 3 - First ZWNJ before a register shifter
0N/A // It can only be followed by a shifter or a vowel
0N/A {-1, -1, -1, -1, 15, -1, -1, 6, 16, 17, 1, 14}, // 4 - First register shifter
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, 20, -1, 1, -1}, // 5 - Robat
0N/A {-1, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1}, // 6 - First Coeng
0N/A {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 7 - First consonant of type 1 after coeng
0N/A {-1, -1, -1, -1, 12, 13, -1, -1, 16, 17, 1, 14}, // 8 - First consonant of type 2 after coeng
0N/A {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 9 - First consonant or type 3 after ceong
0N/A {-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, // 10 - Second Coeng (no register shifter before)
1693N/A {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 11 - Second coeng consonant (or ind. vowel) no register shifter before
3171N/A {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, // 12 - Second ZWNJ before a register shifter
0N/A {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 13 - Second register shifter
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 14 - ZWJ before vowel
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 15 - ZWNJ before vowel
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 1, 18}, // 16 - dependent vowel
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 18}, // 17 - sign above
0N/A {-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, // 18 - ZWJ after vowel
0N/A {-1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, // 19 - Third coeng
0N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, // 20 - dependent vowel after a Robat
1693N/A
0N/A};
0N/A
0N/A
0N/Aconst FeatureMap *KhmerReordering::getFeatureMap(le_int32 &count)
0N/A{
0N/A count = featureMapCount;
0N/A
0N/A return featureMap;
0N/A}
0N/A
0N/A
0N/A// Given an input string of characters and a location in which to start looking
0N/A// calculate, using the state table, which one is the last character of the syllable
0N/A// that starts in the starting position.
1693N/Ale_int32 KhmerReordering::findSyllable(const KhmerClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
0N/A{
0N/A le_int32 cursor = prev;
0N/A le_int8 state = 0;
0N/A
0N/A while (cursor < charCount) {
1693N/A KhmerClassTable::CharClass charClass = (classTable->getCharClass(chars[cursor]) & KhmerClassTable::CF_CLASS_MASK);
0N/A
0N/A state = khmerStateTable[state][charClass];
0N/A
0N/A if (state < 0) {
0N/A break;
0N/A }
0N/A
0N/A cursor += 1;
0N/A }
0N/A
0N/A return cursor;
0N/A}
0N/A
0N/A
0N/A// This is the real reordering function as applied to the Khmer language
0N/A
1693N/Ale_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32 /*scriptCode*/,
1693N/A LEUnicode *outChars, LEGlyphStorage &glyphStorage)
0N/A{
0N/A const KhmerClassTable *classTable = KhmerClassTable::getKhmerClassTable();
0N/A
3171N/A KhmerReorderingOutput output(outChars, glyphStorage);
0N/A KhmerClassTable::CharClass charClass;
0N/A le_int32 i, prev = 0, coengRo;
0N/A
0N/A
0N/A // This loop only exits when we reach the end of a run, which may contain
0N/A // several syllables.
0N/A while (prev < charCount) {
0N/A le_int32 syllable = findSyllable(classTable, chars, prev, charCount);
0N/A
3171N/A output.reset();
3171N/A
0N/A // write a pre vowel or the pre part of a split vowel first
0N/A // and look out for coeng + ro. RO is the only vowel of type 2, and
0N/A // therefore the only one that requires saving space before the base.
0N/A coengRo = -1; // There is no Coeng Ro, if found this value will change
0N/A for (i = prev; i < syllable; i += 1) {
0N/A charClass = classTable->getCharClass(chars[i]);
0N/A
0N/A // if a split vowel, write the pre part. In Khmer the pre part
0N/A // is the same for all split vowels, same glyph as pre vowel C_VOWEL_E
0N/A if (charClass & KhmerClassTable::CF_SPLIT_VOWEL) {
0N/A output.writeChar(C_VOWEL_E, i, tagPref);
0N/A break; // there can be only one vowel
0N/A }
0N/A
0N/A // if a vowel with pos before write it out
0N/A if (charClass & KhmerClassTable::CF_POS_BEFORE) {
0N/A output.writeChar(chars[i], i, tagPref);
0N/A break; // there can be only one vowel
0N/A }
0N/A
0N/A // look for coeng + ro and remember position
0N/A // works because coeng + ro is always in front of a vowel (if there is a vowel)
0N/A // and because CC_CONSONANT2 is enough to identify it, as it is the only consonant
0N/A // with this flag
0N/A if ( (charClass & KhmerClassTable::CF_COENG) && (i + 1 < syllable) &&
1693N/A ( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK) == KhmerClassTable::CC_CONSONANT2) )
0N/A {
0N/A coengRo = i;
0N/A }
0N/A }
0N/A
0N/A // write coeng + ro if found
0N/A if (coengRo > -1) {
0N/A output.writeChar(C_COENG, coengRo, tagPref);
0N/A output.writeChar(C_RO, coengRo + 1, tagPref);
0N/A }
0N/A
1693N/A // shall we add a dotted circle?
1693N/A // If in the position in which the base should be (first char in the string) there is
1693N/A // a character that has the Dotted circle flag (a character that cannot be a base)
1693N/A // then write a dotted circle
0N/A if (classTable->getCharClass(chars[prev]) & KhmerClassTable::CF_DOTTED_CIRCLE) {
0N/A output.writeChar(C_DOTTED_CIRCLE, prev, tagDefault);
0N/A }
0N/A
1693N/A // copy what is left to the output, skipping before vowels and coeng Ro if they are present
0N/A for (i = prev; i < syllable; i += 1) {
0N/A charClass = classTable->getCharClass(chars[i]);
0N/A
0N/A // skip a before vowel, it was already processed
0N/A if (charClass & KhmerClassTable::CF_POS_BEFORE) {
0N/A continue;
0N/A }
0N/A
0N/A // skip coeng + ro, it was already processed
0N/A if (i == coengRo) {
0N/A i += 1;
0N/A continue;
0N/A }
0N/A
0N/A switch (charClass & KhmerClassTable::CF_POS_MASK) {
0N/A case KhmerClassTable::CF_POS_ABOVE :
0N/A output.writeChar(chars[i], i, tagAbvf);
0N/A break;
0N/A
0N/A case KhmerClassTable::CF_POS_AFTER :
0N/A output.writeChar(chars[i], i, tagPstf);
0N/A break;
0N/A
0N/A case KhmerClassTable::CF_POS_BELOW :
0N/A output.writeChar(chars[i], i, tagBlwf);
0N/A break;
0N/A
0N/A default:
0N/A // assign the correct flags to a coeng consonant
0N/A // Consonants of type 3 are taged as Post forms and those type 1 as below forms
0N/A if ( (charClass & KhmerClassTable::CF_COENG) && i + 1 < syllable ) {
0N/A if ( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK)
0N/A == KhmerClassTable::CC_CONSONANT3) {
0N/A output.writeChar(chars[i], i, tagPstf);
0N/A i += 1;
0N/A output.writeChar(chars[i], i, tagPstf);
0N/A }
0N/A else {
0N/A output.writeChar(chars[i], i, tagBlwf);
0N/A i += 1;
0N/A output.writeChar(chars[i], i, tagBlwf);
0N/A }
0N/A break;
0N/A }
0N/A // if a shifter is followed by an above vowel change the shifter to below form,
0N/A // an above vowel can have two possible positions i + 1 or i + 3
0N/A // (position i+1 corresponds to unicode 3, position i+3 to Unicode 4)
0N/A // and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two
0N/A // different positions, right after the shifter or after a vowel (Unicode 4)
0N/A if ( (charClass & KhmerClassTable::CF_SHIFTER) && (i + 1 < syllable) ) {
1693N/A if ((classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_ABOVE_VOWEL)
1693N/A || (i + 2 < syllable
1693N/A && ( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA)
1693N/A && ( (classTable->getCharClass(chars[i + 2]) & KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT))
1693N/A || (i + 3 < syllable && (classTable->getCharClass(chars[i + 3]) & KhmerClassTable::CF_ABOVE_VOWEL))
1693N/A || (i + 4 < syllable
1693N/A && ( (classTable->getCharClass(chars[i + 3]) & KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA)
1693N/A && ( (classTable->getCharClass(chars[i + 4]) & KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT) ) )
0N/A {
0N/A output.writeChar(chars[i], i, tagBlwf);
0N/A break;
0N/A }
0N/A
0N/A }
0N/A // default - any other characters
0N/A output.writeChar(chars[i], i, tagDefault);
0N/A break;
0N/A } // switch
0N/A } // for
0N/A
0N/A prev = syllable; // move the pointer to the start of next syllable
0N/A }
0N/A
0N/A return output.getOutputIndex();
0N/A}
1693N/A
1693N/A
1693N/AU_NAMESPACE_END