1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/uconv/ucvko/nsCP949ToUnicode.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsCP949ToUnicode.h" 1.10 +#include "nsUCvKODll.h" 1.11 +#include "nsUCConstructors.h" 1.12 + 1.13 +//---------------------------------------------------------------------- 1.14 +// Global functions and data [declaration] 1.15 + 1.16 +static const uScanClassID g_CP949ScanClassIDs[] = { 1.17 + u1ByteCharset, 1.18 +// This is necessary to decode 8byte sequence representation of Hangul 1.19 +// syllables. This representation is uniq to EUC-KR and is not used 1.20 +// in CP949. However, this converter is for both EUC-KR and CP949 1.21 +// so that this class ID is put here. See bug 131388. 1.22 + uDecomposedHangulCharset, 1.23 + u2BytesGRCharset, // EUC_KR 1.24 + u2BytesGR128Charset, // CP949 High 1.25 + u2BytesCharset // CP949 Low 1.26 +}; 1.27 + 1.28 +// CP949(non-EUC-KR portion) to Unicode 1.29 +static const uint16_t g_utCP949NoKSCHangulMapping[] = { 1.30 +#include "u20cp949hangul.ut" 1.31 +}; 1.32 + 1.33 +static const uRange g_CP949Ranges[] = { 1.34 + { 0x00, 0x7F }, 1.35 + { 0xA4, 0xA4 }, // 8byte seq. for Hangul syllables not available 1.36 + // in pre-composed form in KS X 1001 1.37 + { 0xA1, 0xFE }, 1.38 + { 0xA1, 0xC6 }, // CP949 extension B. ends at 0xC6. 1.39 + { 0x80, 0xA0 } 1.40 +}; 1.41 + 1.42 +static const uint16_t *g_CP949MappingTableSet [] ={ 1.43 + g_ASCIIMappingTable, 1.44 + g_HangulNullMapping, 1.45 + g_utKSC5601Mapping, 1.46 + g_utCP949NoKSCHangulMapping, 1.47 + g_utCP949NoKSCHangulMapping 1.48 +//g_CP949HighMapping, 1.49 +//g_CP949LowMapping 1.50 +}; 1.51 + 1.52 + 1.53 +nsresult 1.54 +nsCP949ToUnicodeConstructor(nsISupports *aOuter, REFNSIID aIID, 1.55 + void **aResult) 1.56 +{ 1.57 + return CreateMultiTableDecoder(sizeof(g_CP949Ranges) / sizeof(g_CP949Ranges[0]), 1.58 + (const uRange*) &g_CP949Ranges, 1.59 + (uScanClassID*) &g_CP949ScanClassIDs, 1.60 + (uMappingTable**) &g_CP949MappingTableSet, 1, 1.61 + aOuter, aIID, aResult); 1.62 +} 1.63 +