Back to index

lightning-sunbird  0.9+nobinonly
gbku.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Intel Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1999
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Yueheng Xu <yueheng.xu@intel.com>
00023  *   Hoa Nguyen <hoa.nguyen@intel.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 // =======================================================================
00039 // Original Author: Yueheng Xu
00040 // email: yueheng.xu@intel.com
00041 // phone: (503)264-2248
00042 // Intel Corporation, Oregon, USA
00043 // Last Update: September 7, 1999
00044 // Revision History: 
00045 // 09/07/1999 - initial version.
00046 // 09/28/1999 - changed leftbyte and rightbyte from char to unsigned char 
00047 //              in struct DByte
00048 // 04/10/1999 - changed leftbyte. rightbyte to PRUint8 in struct DByte;
00049 //              added table UnicodeToGBKTable[0x5200]
00050 //            
00051 // 05/16/2000 - added gUnicodeToGBKTableInitialized flag for optimization
00052 // ======================================================================================
00053 // Table GBKToUnicode[] maps the GBK code to its unicode.
00054 // The mapping data of this GBK table is obtained from 
00055 // ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
00056 // Frank Tang of Netscape wrote the original perl tool to re-align the 
00057 // mapping data into an 8-item per line format ( i.e. file cp936map.txt ).
00058 //
00059 // The valid GBK charset range: left byte is [0x81, 0xfe], right byte are
00060 // [0x40, 0x7e] and [0x80, 0xfe]. But for the convenience of index 
00061 // calculation, the table here has a single consecutive range of 
00062 // [0x40, 0xfe] for the right byte. Those invalid chars whose right byte 
00063 // is 0x7f will be mapped to undefined unicode 0xFFFF.
00064 //
00065 // 
00066 // Table UnicodeToGBK[] maps the unicode to GBK code. To reduce memory usage, we
00067 // only do Unicode to GBK table mapping for unicode between 0x4E00 and 0xA000; 
00068 // Others let converter to do search from table GBKToUnicode[]. If we want further
00069 // trade memory for performance, we can let more unicode to do table mapping to get
00070 // its GBK instead of searching table GBKToUnicode[]. 
00071 #ifndef _GBKU_H__
00072 #define _GBKU_H__
00073 
00074 
00075 #define  UCS2_NO_MAPPING ((PRUnichar) 0xfffd)
00076 #define UINT8_IN_RANGE(a, b, c) \
00077  (((PRUint8)(a) <= (PRUint8)(b))&&((PRUint8)(b) <= (PRUint8)(c)))
00078 #define UNICHAR_IN_RANGE(a, b, c) \
00079  (((PRUnichar)(a) <= (PRUnichar)(b))&&((PRUnichar)(b) <= (PRUnichar)(c)))
00080 #define CAST_CHAR_TO_UNICHAR(a) ((PRUnichar)((unsigned char)(a)))
00081 #define CAST_UNICHAR_TO_CHAR(a) ((char)a)
00082 
00083 #define IS_ASCII(a) (0==(0xff80 & (a)))
00084 #define IS_GBK_EURO(c) ((char)0x80 == (c))
00085 #define UCS2_EURO  ((PRUnichar) 0x20ac)
00086 
00087 #include "nsGBKConvUtil.h"
00088 
00089 #endif /* _GBKU_H__ */