nsEscSM.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsCodingStateMachine.h"
  38. static const PRUint32 HZ_cls[ 256 / 8 ] = {
  39. PCK4BITS(1,0,0,0,0,0,0,0), // 00 - 07
  40. PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
  41. PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
  42. PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
  43. PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27
  44. PCK4BITS(0,0,0,0,0,0,0,0), // 28 - 2f
  45. PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
  46. PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
  47. PCK4BITS(0,0,0,0,0,0,0,0), // 40 - 47
  48. PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
  49. PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
  50. PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
  51. PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
  52. PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
  53. PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
  54. PCK4BITS(0,0,0,4,0,5,2,0), // 78 - 7f
  55. PCK4BITS(1,1,1,1,1,1,1,1), // 80 - 87
  56. PCK4BITS(1,1,1,1,1,1,1,1), // 88 - 8f
  57. PCK4BITS(1,1,1,1,1,1,1,1), // 90 - 97
  58. PCK4BITS(1,1,1,1,1,1,1,1), // 98 - 9f
  59. PCK4BITS(1,1,1,1,1,1,1,1), // a0 - a7
  60. PCK4BITS(1,1,1,1,1,1,1,1), // a8 - af
  61. PCK4BITS(1,1,1,1,1,1,1,1), // b0 - b7
  62. PCK4BITS(1,1,1,1,1,1,1,1), // b8 - bf
  63. PCK4BITS(1,1,1,1,1,1,1,1), // c0 - c7
  64. PCK4BITS(1,1,1,1,1,1,1,1), // c8 - cf
  65. PCK4BITS(1,1,1,1,1,1,1,1), // d0 - d7
  66. PCK4BITS(1,1,1,1,1,1,1,1), // d8 - df
  67. PCK4BITS(1,1,1,1,1,1,1,1), // e0 - e7
  68. PCK4BITS(1,1,1,1,1,1,1,1), // e8 - ef
  69. PCK4BITS(1,1,1,1,1,1,1,1), // f0 - f7
  70. PCK4BITS(1,1,1,1,1,1,1,1) // f8 - ff
  71. };
  72. static const PRUint32 HZ_st [ 6] = {
  73. PCK4BITS(eStart,eError, 3,eStart,eStart,eStart,eError,eError),//00-07
  74. PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
  75. PCK4BITS(eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError),//10-17
  76. PCK4BITS( 5,eError, 6,eError, 5, 5, 4,eError),//18-1f
  77. PCK4BITS( 4,eError, 4, 4, 4,eError, 4,eError),//20-27
  78. PCK4BITS( 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart) //28-2f
  79. };
  80. static const PRUint32 HZCharLenTable[] = {0, 0, 0, 0, 0, 0};
  81. const SMModel HZSMModel = {
  82. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_cls },
  83. 6,
  84. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, HZ_st },
  85. HZCharLenTable,
  86. "HZ-GB-2312",
  87. };
  88. static const PRUint32 ISO2022CN_cls [ 256 / 8 ] = {
  89. PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
  90. PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
  91. PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
  92. PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
  93. PCK4BITS(0,0,0,0,0,0,0,0), // 20 - 27
  94. PCK4BITS(0,3,0,0,0,0,0,0), // 28 - 2f
  95. PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
  96. PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
  97. PCK4BITS(0,0,0,4,0,0,0,0), // 40 - 47
  98. PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
  99. PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
  100. PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
  101. PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
  102. PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
  103. PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
  104. PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
  105. PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
  106. PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
  107. PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
  108. PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
  109. PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
  110. PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
  111. PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
  112. PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
  113. PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
  114. PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
  115. PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
  116. PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
  117. PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
  118. PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
  119. PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
  120. PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
  121. };
  122. static const PRUint32 ISO2022CN_st [ 8] = {
  123. PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07
  124. PCK4BITS(eStart,eError,eError,eError,eError,eError,eError,eError),//08-0f
  125. PCK4BITS(eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe),//10-17
  126. PCK4BITS(eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError),//18-1f
  127. PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//20-27
  128. PCK4BITS( 5, 6,eError,eError,eError,eError,eError,eError),//28-2f
  129. PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//30-37
  130. PCK4BITS(eError,eError,eError,eError,eError,eItsMe,eError,eStart) //38-3f
  131. };
  132. static const PRUint32 ISO2022CNCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  133. const SMModel ISO2022CNSMModel = {
  134. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_cls },
  135. 9,
  136. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022CN_st },
  137. ISO2022CNCharLenTable,
  138. "ISO-2022-CN",
  139. };
  140. static const PRUint32 ISO2022JP_cls [ 256 / 8 ] = {
  141. PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
  142. PCK4BITS(0,0,0,0,0,0,2,2), // 08 - 0f
  143. PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
  144. PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
  145. PCK4BITS(0,0,0,0,7,0,0,0), // 20 - 27
  146. PCK4BITS(3,0,0,0,0,0,0,0), // 28 - 2f
  147. PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
  148. PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
  149. PCK4BITS(6,0,4,0,8,0,0,0), // 40 - 47
  150. PCK4BITS(0,9,5,0,0,0,0,0), // 48 - 4f
  151. PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
  152. PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
  153. PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
  154. PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
  155. PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
  156. PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
  157. PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
  158. PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
  159. PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
  160. PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
  161. PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
  162. PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
  163. PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
  164. PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
  165. PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
  166. PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
  167. PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
  168. PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
  169. PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
  170. PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
  171. PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
  172. PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
  173. };
  174. static const PRUint32 ISO2022JP_st [ 9] = {
  175. PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eStart,eStart),//00-07
  176. PCK4BITS(eStart,eStart,eError,eError,eError,eError,eError,eError),//08-0f
  177. PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//10-17
  178. PCK4BITS(eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError),//18-1f
  179. PCK4BITS(eError, 5,eError,eError,eError, 4,eError,eError),//20-27
  180. PCK4BITS(eError,eError,eError, 6,eItsMe,eError,eItsMe,eError),//28-2f
  181. PCK4BITS(eError,eError,eError,eError,eError,eError,eItsMe,eItsMe),//30-37
  182. PCK4BITS(eError,eError,eError,eItsMe,eError,eError,eError,eError),//38-3f
  183. PCK4BITS(eError,eError,eError,eError,eItsMe,eError,eStart,eStart) //40-47
  184. };
  185. static const PRUint32 ISO2022JPCharLenTable[] = {0, 0, 0, 0, 0, 0, 0, 0};
  186. const SMModel ISO2022JPSMModel = {
  187. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_cls },
  188. 10,
  189. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022JP_st },
  190. ISO2022JPCharLenTable,
  191. "ISO-2022-JP",
  192. };
  193. static const PRUint32 ISO2022KR_cls [ 256 / 8 ] = {
  194. PCK4BITS(2,0,0,0,0,0,0,0), // 00 - 07
  195. PCK4BITS(0,0,0,0,0,0,0,0), // 08 - 0f
  196. PCK4BITS(0,0,0,0,0,0,0,0), // 10 - 17
  197. PCK4BITS(0,0,0,1,0,0,0,0), // 18 - 1f
  198. PCK4BITS(0,0,0,0,3,0,0,0), // 20 - 27
  199. PCK4BITS(0,4,0,0,0,0,0,0), // 28 - 2f
  200. PCK4BITS(0,0,0,0,0,0,0,0), // 30 - 37
  201. PCK4BITS(0,0,0,0,0,0,0,0), // 38 - 3f
  202. PCK4BITS(0,0,0,5,0,0,0,0), // 40 - 47
  203. PCK4BITS(0,0,0,0,0,0,0,0), // 48 - 4f
  204. PCK4BITS(0,0,0,0,0,0,0,0), // 50 - 57
  205. PCK4BITS(0,0,0,0,0,0,0,0), // 58 - 5f
  206. PCK4BITS(0,0,0,0,0,0,0,0), // 60 - 67
  207. PCK4BITS(0,0,0,0,0,0,0,0), // 68 - 6f
  208. PCK4BITS(0,0,0,0,0,0,0,0), // 70 - 77
  209. PCK4BITS(0,0,0,0,0,0,0,0), // 78 - 7f
  210. PCK4BITS(2,2,2,2,2,2,2,2), // 80 - 87
  211. PCK4BITS(2,2,2,2,2,2,2,2), // 88 - 8f
  212. PCK4BITS(2,2,2,2,2,2,2,2), // 90 - 97
  213. PCK4BITS(2,2,2,2,2,2,2,2), // 98 - 9f
  214. PCK4BITS(2,2,2,2,2,2,2,2), // a0 - a7
  215. PCK4BITS(2,2,2,2,2,2,2,2), // a8 - af
  216. PCK4BITS(2,2,2,2,2,2,2,2), // b0 - b7
  217. PCK4BITS(2,2,2,2,2,2,2,2), // b8 - bf
  218. PCK4BITS(2,2,2,2,2,2,2,2), // c0 - c7
  219. PCK4BITS(2,2,2,2,2,2,2,2), // c8 - cf
  220. PCK4BITS(2,2,2,2,2,2,2,2), // d0 - d7
  221. PCK4BITS(2,2,2,2,2,2,2,2), // d8 - df
  222. PCK4BITS(2,2,2,2,2,2,2,2), // e0 - e7
  223. PCK4BITS(2,2,2,2,2,2,2,2), // e8 - ef
  224. PCK4BITS(2,2,2,2,2,2,2,2), // f0 - f7
  225. PCK4BITS(2,2,2,2,2,2,2,2) // f8 - ff
  226. };
  227. static const PRUint32 ISO2022KR_st [ 5] = {
  228. PCK4BITS(eStart, 3,eError,eStart,eStart,eStart,eError,eError),//00-07
  229. PCK4BITS(eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe),//08-0f
  230. PCK4BITS(eItsMe,eItsMe,eError,eError,eError, 4,eError,eError),//10-17
  231. PCK4BITS(eError,eError,eError,eError, 5,eError,eError,eError),//18-1f
  232. PCK4BITS(eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart) //20-27
  233. };
  234. static const PRUint32 ISO2022KRCharLenTable[] = {0, 0, 0, 0, 0, 0};
  235. const SMModel ISO2022KRSMModel = {
  236. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_cls },
  237. 6,
  238. {eIdxSft4bits, eSftMsk4bits, eBitSft4bits, eUnitMsk4bits, ISO2022KR_st },
  239. ISO2022KRCharLenTable,
  240. "ISO-2022-KR",
  241. };