Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsCP949ToUnicode.h"
7 #include "nsUCvKODll.h"
8 #include "nsUCConstructors.h"
10 //----------------------------------------------------------------------
11 // Global functions and data [declaration]
13 static const uScanClassID g_CP949ScanClassIDs[] = {
14 u1ByteCharset,
15 // This is necessary to decode 8byte sequence representation of Hangul
16 // syllables. This representation is uniq to EUC-KR and is not used
17 // in CP949. However, this converter is for both EUC-KR and CP949
18 // so that this class ID is put here. See bug 131388.
19 uDecomposedHangulCharset,
20 u2BytesGRCharset, // EUC_KR
21 u2BytesGR128Charset, // CP949 High
22 u2BytesCharset // CP949 Low
23 };
25 // CP949(non-EUC-KR portion) to Unicode
26 static const uint16_t g_utCP949NoKSCHangulMapping[] = {
27 #include "u20cp949hangul.ut"
28 };
30 static const uRange g_CP949Ranges[] = {
31 { 0x00, 0x7F },
32 { 0xA4, 0xA4 }, // 8byte seq. for Hangul syllables not available
33 // in pre-composed form in KS X 1001
34 { 0xA1, 0xFE },
35 { 0xA1, 0xC6 }, // CP949 extension B. ends at 0xC6.
36 { 0x80, 0xA0 }
37 };
39 static const uint16_t *g_CP949MappingTableSet [] ={
40 g_ASCIIMappingTable,
41 g_HangulNullMapping,
42 g_utKSC5601Mapping,
43 g_utCP949NoKSCHangulMapping,
44 g_utCP949NoKSCHangulMapping
45 //g_CP949HighMapping,
46 //g_CP949LowMapping
47 };
50 nsresult
51 nsCP949ToUnicodeConstructor(nsISupports *aOuter, REFNSIID aIID,
52 void **aResult)
53 {
54 return CreateMultiTableDecoder(sizeof(g_CP949Ranges) / sizeof(g_CP949Ranges[0]),
55 (const uRange*) &g_CP949Ranges,
56 (uScanClassID*) &g_CP949ScanClassIDs,
57 (uMappingTable**) &g_CP949MappingTableSet, 1,
58 aOuter, aIID, aResult);
59 }