extensions/universalchardet/src/base/nsEscSM.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/universalchardet/src/base/nsEscSM.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,231 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +#include "nsCodingStateMachine.h"
     1.9 +
    1.10 +static const uint32_t HZ_cls[ 256 / 8 ] = {
    1.11 +PCK4BITS(1,0,0,0,0,0,0,0),  // 00 - 07 
    1.12 +PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
    1.13 +PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
    1.14 +PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
    1.15 +PCK4BITS(0,0,0,0,0,0,0,0),  // 20 - 27 
    1.16 +PCK4BITS(0,0,0,0,0,0,0,0),  // 28 - 2f 
    1.17 +PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
    1.18 +PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
    1.19 +PCK4BITS(0,0,0,0,0,0,0,0),  // 40 - 47 
    1.20 +PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
    1.21 +PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
    1.22 +PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
    1.23 +PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
    1.24 +PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
    1.25 +PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
    1.26 +PCK4BITS(0,0,0,4,0,5,2,0),  // 78 - 7f 
    1.27 +PCK4BITS(1,1,1,1,1,1,1,1),  // 80 - 87 
    1.28 +PCK4BITS(1,1,1,1,1,1,1,1),  // 88 - 8f 
    1.29 +PCK4BITS(1,1,1,1,1,1,1,1),  // 90 - 97 
    1.30 +PCK4BITS(1,1,1,1,1,1,1,1),  // 98 - 9f 
    1.31 +PCK4BITS(1,1,1,1,1,1,1,1),  // a0 - a7 
    1.32 +PCK4BITS(1,1,1,1,1,1,1,1),  // a8 - af 
    1.33 +PCK4BITS(1,1,1,1,1,1,1,1),  // b0 - b7 
    1.34 +PCK4BITS(1,1,1,1,1,1,1,1),  // b8 - bf 
    1.35 +PCK4BITS(1,1,1,1,1,1,1,1),  // c0 - c7 
    1.36 +PCK4BITS(1,1,1,1,1,1,1,1),  // c8 - cf 
    1.37 +PCK4BITS(1,1,1,1,1,1,1,1),  // d0 - d7 
    1.38 +PCK4BITS(1,1,1,1,1,1,1,1),  // d8 - df 
    1.39 +PCK4BITS(1,1,1,1,1,1,1,1),  // e0 - e7 
    1.40 +PCK4BITS(1,1,1,1,1,1,1,1),  // e8 - ef 
    1.41 +PCK4BITS(1,1,1,1,1,1,1,1),  // f0 - f7 
    1.42 +PCK4BITS(1,1,1,1,1,1,1,1)   // f8 - ff 
    1.43 +};
    1.44 +
    1.45 +
    1.46 +static const uint32_t HZ_st [ 6] = {
    1.47 +PCK4BITS(eStart,eError,     3,eStart,eStart,eStart,eError,eError),//00-07 
    1.48 +PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f 
    1.49 +PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart,     4,eError),//10-17 
    1.50 +PCK4BITS(     5,eError,     6,eError,     5,     5,     4,eError),//18-1f 
    1.51 +PCK4BITS(     4,eError,     4,     4,     4,eError,     4,eError),//20-27 
    1.52 +PCK4BITS(     4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f 
    1.53 +};
    1.54 +
    1.55 +static const uint32_t HZCharLenTable[] = {0, 0, 0, 0, 0, 0};
    1.56 +
    1.57 +const SMModel HZSMModel = {
    1.58 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls },
    1.59 +   6,
    1.60 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st },
    1.61 +  CHAR_LEN_TABLE(HZCharLenTable),
    1.62 +  "HZ-GB-2312",
    1.63 +};
    1.64 +
    1.65 +
    1.66 +static const uint32_t ISO2022CN_cls [ 256 / 8 ] = {
    1.67 +PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
    1.68 +PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
    1.69 +PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
    1.70 +PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
    1.71 +PCK4BITS(0,0,0,0,0,0,0,0),  // 20 - 27 
    1.72 +PCK4BITS(0,3,0,0,0,0,0,0),  // 28 - 2f 
    1.73 +PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
    1.74 +PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
    1.75 +PCK4BITS(0,0,0,4,0,0,0,0),  // 40 - 47 
    1.76 +PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
    1.77 +PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
    1.78 +PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
    1.79 +PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
    1.80 +PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
    1.81 +PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
    1.82 +PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
    1.83 +PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
    1.84 +PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
    1.85 +PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
    1.86 +PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
    1.87 +PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
    1.88 +PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
    1.89 +PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
    1.90 +PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
    1.91 +PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
    1.92 +PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
    1.93 +PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
    1.94 +PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
    1.95 +PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
    1.96 +PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
    1.97 +PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
    1.98 +PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
    1.99 +};
   1.100 +
   1.101 +
   1.102 +static const uint32_t ISO2022CN_st [ 8] = {
   1.103 +PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 
   1.104 +PCK4BITS(eStart,eError,eError,eError,eError,eError,eError,eError),//08-0f 
   1.105 +PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 
   1.106 +PCK4BITS(eItsMe,eItsMe,eItsMe,eError,eError,eError,     4,eError),//18-1f 
   1.107 +PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//20-27 
   1.108 +PCK4BITS(     5,     6,eError,eError,eError,eError,eError,eError),//28-2f 
   1.109 +PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//30-37 
   1.110 +PCK4BITS(eError,eError,eError,eError,eError,eItsMe,eError,eStart) //38-3f 
   1.111 +};
   1.112 +
   1.113 +static const uint32_t ISO2022CNCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
   1.114 +
   1.115 +const SMModel ISO2022CNSMModel = {
   1.116 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls },
   1.117 +  9,
   1.118 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st },
   1.119 +  CHAR_LEN_TABLE(ISO2022CNCharLenTable),
   1.120 +  "ISO-2022-CN",
   1.121 +};
   1.122 +
   1.123 +static const uint32_t ISO2022JP_cls [ 256 / 8 ] = {
   1.124 +PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
   1.125 +PCK4BITS(0,0,0,0,0,0,2,2),  // 08 - 0f 
   1.126 +PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
   1.127 +PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
   1.128 +PCK4BITS(0,0,0,0,7,0,0,0),  // 20 - 27 
   1.129 +PCK4BITS(3,0,0,0,0,0,0,0),  // 28 - 2f 
   1.130 +PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
   1.131 +PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
   1.132 +PCK4BITS(6,0,4,0,8,0,0,0),  // 40 - 47 
   1.133 +PCK4BITS(0,9,5,0,0,0,0,0),  // 48 - 4f 
   1.134 +PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
   1.135 +PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
   1.136 +PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
   1.137 +PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
   1.138 +PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
   1.139 +PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
   1.140 +PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
   1.141 +PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
   1.142 +PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
   1.143 +PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
   1.144 +PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
   1.145 +PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
   1.146 +PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
   1.147 +PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
   1.148 +PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
   1.149 +PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
   1.150 +PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
   1.151 +PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
   1.152 +PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
   1.153 +PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
   1.154 +PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
   1.155 +PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
   1.156 +};
   1.157 +
   1.158 +
   1.159 +static const uint32_t ISO2022JP_st [ 9] = {
   1.160 +PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eStart,eStart),//00-07 
   1.161 +PCK4BITS(eStart,eStart,eError,eError,eError,eError,eError,eError),//08-0f 
   1.162 +PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//10-17 
   1.163 +PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError),//18-1f 
   1.164 +PCK4BITS(eError,     5,eError,eError,eError,     4,eError,eError),//20-27 
   1.165 +PCK4BITS(eError,eError,eError,     6,eItsMe,eError,eItsMe,eError),//28-2f 
   1.166 +PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//30-37 
   1.167 +PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f 
   1.168 +PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47 
   1.169 +};
   1.170 +
   1.171 +static const uint32_t ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
   1.172 +
   1.173 +const SMModel ISO2022JPSMModel = {
   1.174 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls },
   1.175 +  10,
   1.176 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st },
   1.177 +  CHAR_LEN_TABLE(ISO2022JPCharLenTable),
   1.178 +  "ISO-2022-JP",
   1.179 +};
   1.180 +
   1.181 +static const uint32_t ISO2022KR_cls [ 256 / 8 ] = {
   1.182 +PCK4BITS(2,0,0,0,0,0,0,0),  // 00 - 07 
   1.183 +PCK4BITS(0,0,0,0,0,0,0,0),  // 08 - 0f 
   1.184 +PCK4BITS(0,0,0,0,0,0,0,0),  // 10 - 17 
   1.185 +PCK4BITS(0,0,0,1,0,0,0,0),  // 18 - 1f 
   1.186 +PCK4BITS(0,0,0,0,3,0,0,0),  // 20 - 27 
   1.187 +PCK4BITS(0,4,0,0,0,0,0,0),  // 28 - 2f 
   1.188 +PCK4BITS(0,0,0,0,0,0,0,0),  // 30 - 37 
   1.189 +PCK4BITS(0,0,0,0,0,0,0,0),  // 38 - 3f 
   1.190 +PCK4BITS(0,0,0,5,0,0,0,0),  // 40 - 47 
   1.191 +PCK4BITS(0,0,0,0,0,0,0,0),  // 48 - 4f 
   1.192 +PCK4BITS(0,0,0,0,0,0,0,0),  // 50 - 57 
   1.193 +PCK4BITS(0,0,0,0,0,0,0,0),  // 58 - 5f 
   1.194 +PCK4BITS(0,0,0,0,0,0,0,0),  // 60 - 67 
   1.195 +PCK4BITS(0,0,0,0,0,0,0,0),  // 68 - 6f 
   1.196 +PCK4BITS(0,0,0,0,0,0,0,0),  // 70 - 77 
   1.197 +PCK4BITS(0,0,0,0,0,0,0,0),  // 78 - 7f 
   1.198 +PCK4BITS(2,2,2,2,2,2,2,2),  // 80 - 87 
   1.199 +PCK4BITS(2,2,2,2,2,2,2,2),  // 88 - 8f 
   1.200 +PCK4BITS(2,2,2,2,2,2,2,2),  // 90 - 97 
   1.201 +PCK4BITS(2,2,2,2,2,2,2,2),  // 98 - 9f 
   1.202 +PCK4BITS(2,2,2,2,2,2,2,2),  // a0 - a7 
   1.203 +PCK4BITS(2,2,2,2,2,2,2,2),  // a8 - af 
   1.204 +PCK4BITS(2,2,2,2,2,2,2,2),  // b0 - b7 
   1.205 +PCK4BITS(2,2,2,2,2,2,2,2),  // b8 - bf 
   1.206 +PCK4BITS(2,2,2,2,2,2,2,2),  // c0 - c7 
   1.207 +PCK4BITS(2,2,2,2,2,2,2,2),  // c8 - cf 
   1.208 +PCK4BITS(2,2,2,2,2,2,2,2),  // d0 - d7 
   1.209 +PCK4BITS(2,2,2,2,2,2,2,2),  // d8 - df 
   1.210 +PCK4BITS(2,2,2,2,2,2,2,2),  // e0 - e7 
   1.211 +PCK4BITS(2,2,2,2,2,2,2,2),  // e8 - ef 
   1.212 +PCK4BITS(2,2,2,2,2,2,2,2),  // f0 - f7 
   1.213 +PCK4BITS(2,2,2,2,2,2,2,2)   // f8 - ff 
   1.214 +};
   1.215 +
   1.216 +
   1.217 +static const uint32_t ISO2022KR_st [ 5] = {
   1.218 +PCK4BITS(eStart,     3,eError,eStart,eStart,eStart,eError,eError),//00-07 
   1.219 +PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f 
   1.220 +PCK4BITS(eItsMe,eItsMe,eError,eError,eError,     4,eError,eError),//10-17 
   1.221 +PCK4BITS(eError,eError,eError,eError,     5,eError,eError,eError),//18-1f 
   1.222 +PCK4BITS(eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart) //20-27 
   1.223 +};
   1.224 +
   1.225 +static const uint32_t ISO2022KRCharLenTable[] = {0, 0, 0, 0, 0, 0};
   1.226 +
   1.227 +const SMModel ISO2022KRSMModel = {
   1.228 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls },
   1.229 +   6,
   1.230 +  {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st },
   1.231 +  CHAR_LEN_TABLE(ISO2022KRCharLenTable),
   1.232 +  "ISO-2022-KR",
   1.233 +};
   1.234 +

mercurial