intl/uconv/ucvcn/gbku.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/ucvcn/gbku.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +// =======================================================================
     1.8 +// Original Author: Yueheng Xu
     1.9 +// email: yueheng.xu@intel.com
    1.10 +// phone: (503)264-2248
    1.11 +// Intel Corporation, Oregon, USA
    1.12 +// Last Update: September 7, 1999
    1.13 +// Revision History: 
    1.14 +// 09/07/1999 - initial version.
    1.15 +// 09/28/1999 - changed leftbyte and rightbyte from char to unsigned char 
    1.16 +//              in struct DByte
    1.17 +// 04/10/1999 - changed leftbyte. rightbyte to uint8_t in struct DByte;
    1.18 +//              added table UnicodeToGBKTable[0x5200]
    1.19 +//            
    1.20 +// 05/16/2000 - added gUnicodeToGBKTableInitialized flag for optimization
    1.21 +// ======================================================================================
    1.22 +// Table GBKToUnicode[] maps the GBK code to its unicode.
    1.23 +// The mapping data of this GBK table is obtained from 
    1.24 +// ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
    1.25 +// Frank Tang of Netscape wrote the original perl tool to re-align the 
    1.26 +// mapping data into an 8-item per line format ( i.e. file cp936map.txt ).
    1.27 +//
    1.28 +// The valid GBK charset range: left byte is [0x81, 0xfe], right byte are
    1.29 +// [0x40, 0x7e] and [0x80, 0xfe]. But for the convenience of index 
    1.30 +// calculation, the table here has a single consecutive range of 
    1.31 +// [0x40, 0xfe] for the right byte. Those invalid chars whose right byte 
    1.32 +// is 0x7f will be mapped to undefined unicode 0xFFFF.
    1.33 +//
    1.34 +// 
    1.35 +// Table UnicodeToGBK[] maps the unicode to GBK code. To reduce memory usage, we
    1.36 +// only do Unicode to GBK table mapping for unicode between 0x4E00 and 0xA000; 
    1.37 +// Others let converter to do search from table GBKToUnicode[]. If we want further
    1.38 +// trade memory for performance, we can let more unicode to do table mapping to get
    1.39 +// its GBK instead of searching table GBKToUnicode[]. 
    1.40 +#ifndef _GBKU_H__
    1.41 +#define _GBKU_H__
    1.42 +
    1.43 +
    1.44 +#define  UCS2_NO_MAPPING ((char16_t) 0xfffd)
    1.45 +#define UINT8_IN_RANGE(a, b, c) \
    1.46 + (((uint8_t)(a) <= (uint8_t)(b))&&((uint8_t)(b) <= (uint8_t)(c)))
    1.47 +#define UNICHAR_IN_RANGE(a, b, c) \
    1.48 + (((char16_t)(a) <= (char16_t)(b))&&((char16_t)(b) <= (char16_t)(c)))
    1.49 +#define CAST_CHAR_TO_UNICHAR(a) ((char16_t)((unsigned char)(a)))
    1.50 +#define CAST_UNICHAR_TO_CHAR(a) ((char)a)
    1.51 +
    1.52 +#define IS_ASCII(a) (0==(0xff80 & (a)))
    1.53 +#define IS_GBK_EURO(c) ((char)0x80 == (c))
    1.54 +#define UCS2_EURO  ((char16_t) 0x20ac)
    1.55 +
    1.56 +#include "nsGBKConvUtil.h"
    1.57 +
    1.58 +#endif /* _GBKU_H__ */

mercurial