nsCP949ToUnicode.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/. */
  5. #include "nsCP949ToUnicode.h"
  6. #include "nsUCvKODll.h"
  7. #include "nsUCConstructors.h"
  8. //----------------------------------------------------------------------
  9. // Global functions and data [declaration]
  10. static const uScanClassID g_CP949ScanClassIDs[] = {
  11. u1ByteCharset,
  12. // This is necessary to decode 8byte sequence representation of Hangul
  13. // syllables. This representation is uniq to EUC-KR and is not used
  14. // in CP949. However, this converter is for both EUC-KR and CP949
  15. // so that this class ID is put here. See bug 131388.
  16. uDecomposedHangulCharset,
  17. u2BytesGRCharset, // EUC_KR
  18. u2BytesGR128Charset, // CP949 High
  19. u2BytesCharset // CP949 Low
  20. };
  21. // CP949(non-EUC-KR portion) to Unicode
  22. static const uint16_t g_utCP949NoKSCHangulMapping[] = {
  23. #include "u20cp949hangul.ut"
  24. };
  25. static const uRange g_CP949Ranges[] = {
  26. { 0x00, 0x7F },
  27. { 0xA4, 0xA4 }, // 8byte seq. for Hangul syllables not available
  28. // in pre-composed form in KS X 1001
  29. { 0xA1, 0xFE },
  30. { 0xA1, 0xC6 }, // CP949 extension B. ends at 0xC6.
  31. { 0x80, 0xA0 }
  32. };
  33. static const uint16_t *g_CP949MappingTableSet [] ={
  34. g_ASCIIMappingTable,
  35. g_HangulNullMapping,
  36. g_utKSC5601Mapping,
  37. g_utCP949NoKSCHangulMapping,
  38. g_utCP949NoKSCHangulMapping
  39. //g_CP949HighMapping,
  40. //g_CP949LowMapping
  41. };
  42. nsresult
  43. nsCP949ToUnicodeConstructor(nsISupports *aOuter, REFNSIID aIID,
  44. void **aResult)
  45. {
  46. return CreateMultiTableDecoder(sizeof(g_CP949Ranges) / sizeof(g_CP949Ranges[0]),
  47. (const uRange*) &g_CP949Ranges,
  48. (uScanClassID*) &g_CP949ScanClassIDs,
  49. (uMappingTable**) &g_CP949MappingTableSet, 1,
  50. aOuter, aIID, aResult);
  51. }