intl/uconv/ucvcn/gbku.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     4 // =======================================================================
     5 // Original Author: Yueheng Xu
     6 // email: yueheng.xu@intel.com
     7 // phone: (503)264-2248
     8 // Intel Corporation, Oregon, USA
     9 // Last Update: September 7, 1999
    10 // Revision History: 
    11 // 09/07/1999 - initial version.
    12 // 09/28/1999 - changed leftbyte and rightbyte from char to unsigned char 
    13 //              in struct DByte
    14 // 04/10/1999 - changed leftbyte. rightbyte to uint8_t in struct DByte;
    15 //              added table UnicodeToGBKTable[0x5200]
    16 //            
    17 // 05/16/2000 - added gUnicodeToGBKTableInitialized flag for optimization
    18 // ======================================================================================
    19 // Table GBKToUnicode[] maps the GBK code to its unicode.
    20 // The mapping data of this GBK table is obtained from 
    21 // ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
    22 // Frank Tang of Netscape wrote the original perl tool to re-align the 
    23 // mapping data into an 8-item per line format ( i.e. file cp936map.txt ).
    24 //
    25 // The valid GBK charset range: left byte is [0x81, 0xfe], right byte are
    26 // [0x40, 0x7e] and [0x80, 0xfe]. But for the convenience of index 
    27 // calculation, the table here has a single consecutive range of 
    28 // [0x40, 0xfe] for the right byte. Those invalid chars whose right byte 
    29 // is 0x7f will be mapped to undefined unicode 0xFFFF.
    30 //
    31 // 
    32 // Table UnicodeToGBK[] maps the unicode to GBK code. To reduce memory usage, we
    33 // only do Unicode to GBK table mapping for unicode between 0x4E00 and 0xA000; 
    34 // Others let converter to do search from table GBKToUnicode[]. If we want further
    35 // trade memory for performance, we can let more unicode to do table mapping to get
    36 // its GBK instead of searching table GBKToUnicode[]. 
    37 #ifndef _GBKU_H__
    38 #define _GBKU_H__
    41 #define  UCS2_NO_MAPPING ((char16_t) 0xfffd)
    42 #define UINT8_IN_RANGE(a, b, c) \
    43  (((uint8_t)(a) <= (uint8_t)(b))&&((uint8_t)(b) <= (uint8_t)(c)))
    44 #define UNICHAR_IN_RANGE(a, b, c) \
    45  (((char16_t)(a) <= (char16_t)(b))&&((char16_t)(b) <= (char16_t)(c)))
    46 #define CAST_CHAR_TO_UNICHAR(a) ((char16_t)((unsigned char)(a)))
    47 #define CAST_UNICHAR_TO_CHAR(a) ((char)a)
    49 #define IS_ASCII(a) (0==(0xff80 & (a)))
    50 #define IS_GBK_EURO(c) ((char)0x80 == (c))
    51 #define UCS2_EURO  ((char16_t) 0x20ac)
    53 #include "nsGBKConvUtil.h"
    55 #endif /* _GBKU_H__ */

mercurial