PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/AKDOA28/ZX.EHR.ResumeParseLib/Encoding/IdentifyEncoding.cs

#
C# | 2523 lines | 2171 code | 142 blank | 210 comment | 232 complexity | 86147ac96d7c57498271e0c74a920e7b MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, Apache-2.0, GPL-2.0, BSD-3-Clause, LGPL-2.0, MIT, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace ZX.EHR.ResumeParseLib
  6. {
  7. #region 文件编码识别类.
  8. /// <summary>
  9. /// 检测字符编码的类
  10. /// <seealso cref="System.IO.Stream"/>
  11. /// <seealso cref="System.Uri"/>
  12. /// <seealso cref="System.IO.FileInfo"/>
  13. /// </summary>
  14. /// <remarks>
  15. /// <![CDATA[
  16. /// <strong>IdentifyEncoding</strong> 用来检测 <see cref="Uri"/>,<see cref="System.IO.FileInfo"/>,<see cref="sbyte"/> 字节数组的编码.
  17. /// Create By lion <br/>
  18. /// 2005-02-21 22:00 <br/>
  19. /// Support .Net Framework v1.1.4322 <br/>
  20. /// WebSite:www.lionsky.net(lion-a AT sohu.com) <br/>
  21. /// ]]>
  22. /// </remarks>
  23. public class IdentifyEncoding
  24. {
  25. #region Fields.....
  26. // Frequency tables to hold the GB, Big5, and EUC-TW character
  27. // frequencies
  28. internal static int[][] GBFreq = new int[94][];
  29. internal static int[][] GBKFreq = new int[126][];
  30. internal static int[][] Big5Freq = new int[94][];
  31. internal static int[][] EUC_TWFreq = new int[94][];
  32. internal static string[] nicename = new string[]
  33. {
  34. "GB2312", "GBK", "HZ", "Big5", "CNS 11643"
  35. , "ISO 2022CN", "UTF-8", "Unicode", "ASCII", "OTHER"
  36. };
  37. #endregion
  38. #region Methods.....
  39. /// <summary>
  40. /// 初始化 <see cref="IdentifyEncoding"/> 的实例
  41. /// </summary>
  42. public IdentifyEncoding()
  43. {
  44. Initialize_Frequencies();
  45. }
  46. #region GetEncodingName.....
  47. /// <summary>
  48. /// 从指定的 <see cref="Uri"/> 中判断编码类型
  49. /// </summary>
  50. /// <param name="testurl">要判断的 <see cref="Uri"/> </param>
  51. /// <returns>返回编码类型("GB2312", "GBK", "HZ", "Big5", "CNS 11643", "ISO 2022CN", "UTF-8", "Unicode", "ASCII", "OTHER")</returns>
  52. /// <example>
  53. /// 以下示例演示了如何调用 <see cref="GetEncodingName"/> 方法:
  54. /// <code>
  55. /// IdentifyEncoding ide = new IdentifyEncoding();
  56. /// Response.Write(ide.GetEncodingName(new Uri("http://china5.nikkeibp.co.jp/china/news/com/200307/pr_com200307170131.html")));
  57. /// </code>
  58. /// </example>
  59. public virtual string GetEncodingName(System.Uri testurl)
  60. {
  61. sbyte[] rawtext = new sbyte[1024];
  62. int bytesread = 0, byteoffset = 0;
  63. System.IO.Stream chinesestream;
  64. try
  65. {
  66. chinesestream = System.Net.WebRequest.Create(testurl.AbsoluteUri).GetResponse().GetResponseStream();
  67. while ((bytesread = ReadInput(chinesestream, ref rawtext, byteoffset, rawtext.Length - byteoffset)) > 0)
  68. {
  69. byteoffset += bytesread;
  70. }
  71. chinesestream.Close();
  72. }
  73. catch (System.Exception e)
  74. {
  75. System.Console.Error.WriteLine("Error loading or using URL " + e.ToString());
  76. }
  77. return GetEncodingName(rawtext);
  78. }
  79. /// <summary>
  80. /// 从指定的 <see cref="System.IO.FileInfo"/> 中判断编码类型
  81. /// </summary>
  82. /// <param name="testfile">要判断的 <see cref="System.IO.FileInfo"/> </param>
  83. /// <returns>返回编码类型("GB2312", "GBK", "HZ", "Big5", "CNS 11643", "ISO 2022CN", "UTF-8", "Unicode", "ASCII", "OTHER")</returns>
  84. /// <example>
  85. /// 以下示例演示了如何调用 <see cref="GetEncodingName"/> 方法:
  86. /// <code>
  87. /// IdentifyEncoding ide = new IdentifyEncoding();
  88. /// Response.Write(ide.GetEncodingName(new System.IO.FileInfo(@"C:\test.txt")));
  89. /// </code>
  90. /// </example>
  91. public virtual string GetEncodingName(System.IO.FileInfo testfile)
  92. {
  93. System.IO.FileStream chinesefile;
  94. sbyte[] rawtext;
  95. rawtext = new sbyte[(int)FileLength(testfile)];
  96. try
  97. {
  98. chinesefile = new System.IO.FileStream(testfile.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
  99. ReadInput(chinesefile, ref rawtext, 0, rawtext.Length);
  100. }
  101. catch (System.Exception e)
  102. {
  103. System.Console.Error.WriteLine("Error: " + e);
  104. }
  105. return GetEncodingName(rawtext);
  106. }
  107. public virtual Encoding GetEncoding(string encodingName)
  108. {
  109. Encoding _encode = Encoding.Default;
  110. if (encodingName.Length == 0)
  111. return _encode;
  112. switch (encodingName)
  113. {
  114. case "UTF-8":
  115. _encode = Encoding.UTF8;
  116. break;
  117. case "Unicode":
  118. _encode = Encoding.Unicode;
  119. break;
  120. }
  121. return _encode;
  122. }
  123. /// <summary>
  124. /// 从指定的 <see cref="sbyte"/> 字节数组中判断编码类型
  125. /// </summary>
  126. /// <param name="rawtext">要判断的 <see cref="System.IO.FileInfo"/> </param>
  127. /// <returns>返回编码类型("GB2312", "GBK", "HZ", "Big5", "CNS 11643", "ISO 2022CN", "UTF-8", "Unicode", "ASCII", "OTHER")</returns>
  128. /// <example>
  129. /// 以下示例演示了如何调用 <see cref="GetEncodingName"/> 方法:
  130. /// <code>
  131. /// IdentifyEncoding ide = new IdentifyEncoding();
  132. /// Response.Write(ide.GetEncodingName(IdentifyEncoding.ToSByteArray(System.Text.Encoding.GetEncoding("gb2312").GetBytes("Lion互动网络(www.lionsky.net)"))));
  133. /// </code>
  134. /// </example>
  135. public virtual string GetEncodingName(sbyte[] rawtext)
  136. {
  137. int[] scores;
  138. int index, maxscore = 0;
  139. int encoding_guess = 0;
  140. scores = new int[10];
  141. //分析编码的概率
  142. scores[0] = GB2312Probability(rawtext);
  143. scores[1] = GBKProbability(rawtext);
  144. scores[2] = HZProbability(rawtext);
  145. scores[3] = BIG5Probability(rawtext);
  146. scores[4] = ENCTWProbability(rawtext);
  147. scores[5] = ISO2022CNProbability(rawtext);
  148. scores[6] = UTF8Probability(rawtext);
  149. scores[7] = UnicodeProbability(rawtext);
  150. scores[8] = ASCIIProbability(rawtext);
  151. scores[9] = 0;
  152. // Tabulate Scores
  153. for (index = 0; index < 10; index++)
  154. {
  155. if (scores[index] > maxscore)
  156. {
  157. encoding_guess = index;
  158. maxscore = scores[index];
  159. }
  160. }
  161. // Return OTHER if nothing scored above 50
  162. if (maxscore <= 50)
  163. {
  164. encoding_guess = 9;
  165. }
  166. return nicename[encoding_guess];
  167. }
  168. #endregion
  169. #region About Probability.....
  170. #region GB2312Probability
  171. /// <summary>
  172. /// 判断是GB2312编码的可能性
  173. /// </summary>
  174. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  175. /// <returns>返回 0 至 100 之间的可能性</returns>
  176. internal virtual int GB2312Probability(sbyte[] rawtext)
  177. {
  178. int i, rawtextlen = 0;
  179. int dbchars = 1, gbchars = 1;
  180. long gbfreq = 0, totalfreq = 1;
  181. float rangeval = 0, freqval = 0;
  182. int row, column;
  183. // Stage 1: Check to see if characters fit into acceptable ranges
  184. rawtextlen = rawtext.Length;
  185. for (i = 0; i < rawtextlen - 1; i++)
  186. {
  187. if (rawtext[i] >= 0)
  188. {
  189. //asciichars++;
  190. }
  191. else
  192. {
  193. dbchars++;
  194. if ((sbyte)Identity(0xA1) <= rawtext[i] && rawtext[i] <= (sbyte)Identity(0xF7) && (sbyte)Identity(0xA1) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xFE))
  195. {
  196. gbchars++;
  197. totalfreq += 500;
  198. row = rawtext[i] + 256 - 0xA1;
  199. column = rawtext[i + 1] + 256 - 0xA1;
  200. if (GBFreq[row][column] != 0)
  201. {
  202. gbfreq += GBFreq[row][column];
  203. }
  204. else if (15 <= row && row < 55)
  205. {
  206. gbfreq += 200;
  207. }
  208. }
  209. i++;
  210. }
  211. }
  212. rangeval = 50 * ((float)gbchars / (float)dbchars);
  213. freqval = 50 * ((float)gbfreq / (float)totalfreq);
  214. return (int)(rangeval + freqval);
  215. }
  216. #endregion
  217. #region GBKProbability.....
  218. /// <summary>
  219. /// 判断是GBK编码的可能性
  220. /// </summary>
  221. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  222. /// <returns>返回 0 至 100 之间的可能性</returns>
  223. internal virtual int GBKProbability(sbyte[] rawtext)
  224. {
  225. int i, rawtextlen = 0;
  226. int dbchars = 1, gbchars = 1;
  227. long gbfreq = 0, totalfreq = 1;
  228. float rangeval = 0, freqval = 0;
  229. int row, column;
  230. // Stage 1: Check to see if characters fit into acceptable ranges
  231. rawtextlen = rawtext.Length;
  232. for (i = 0; i < rawtextlen - 1; i++)
  233. {
  234. if (rawtext[i] >= 0)
  235. {
  236. //asciichars++;
  237. }
  238. else
  239. {
  240. dbchars++;
  241. if ((sbyte)Identity(0xA1) <= rawtext[i] && rawtext[i] <= (sbyte)Identity(0xF7) && (sbyte)Identity(0xA1) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xFE))
  242. {
  243. gbchars++;
  244. totalfreq += 500;
  245. row = rawtext[i] + 256 - 0xA1;
  246. column = rawtext[i + 1] + 256 - 0xA1;
  247. if (GBFreq[row][column] != 0)
  248. {
  249. gbfreq += GBFreq[row][column];
  250. }
  251. else if (15 <= row && row < 55)
  252. {
  253. gbfreq += 200;
  254. }
  255. }
  256. else if ((sbyte)Identity(0x81) <= rawtext[i] && rawtext[i] <= (sbyte)Identity(0xFE) && (((sbyte)Identity(0x80) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xFE)) || ((sbyte)0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)0x7E)))
  257. {
  258. gbchars++;
  259. totalfreq += 500;
  260. row = rawtext[i] + 256 - 0x81;
  261. if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E)
  262. {
  263. column = rawtext[i + 1] - 0x40;
  264. }
  265. else
  266. {
  267. column = rawtext[i + 1] + 256 - 0x80;
  268. }
  269. if (GBKFreq[row][column] != 0)
  270. {
  271. gbfreq += GBKFreq[row][column];
  272. }
  273. }
  274. i++;
  275. }
  276. }
  277. rangeval = 50 * ((float)gbchars / (float)dbchars);
  278. freqval = 50 * ((float)gbfreq / (float)totalfreq);
  279. return (int)(rangeval + freqval) - 1;
  280. }
  281. #endregion
  282. #region HZProbability.....
  283. /// <summary>
  284. /// 判断是HZ编码的可能性
  285. /// </summary>
  286. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  287. /// <returns>返回 0 至 100 之间的可能性</returns>
  288. internal virtual int HZProbability(sbyte[] rawtext)
  289. {
  290. int i, rawtextlen;
  291. int hzchars = 0, dbchars = 1;
  292. long hzfreq = 0, totalfreq = 1;
  293. float rangeval = 0, freqval = 0;
  294. int hzstart = 0, hzend = 0;
  295. int row, column;
  296. rawtextlen = rawtext.Length;
  297. for (i = 0; i < rawtextlen; i++)
  298. {
  299. if (rawtext[i] == '~')
  300. {
  301. if (rawtext[i + 1] == '{')
  302. {
  303. hzstart++;
  304. i += 2;
  305. while (i < rawtextlen - 1)
  306. {
  307. if (rawtext[i] == 0x0A || rawtext[i] == 0x0D)
  308. {
  309. break;
  310. }
  311. else if (rawtext[i] == '~' && rawtext[i + 1] == '}')
  312. {
  313. hzend++;
  314. i++;
  315. break;
  316. }
  317. else if ((0x21 <= rawtext[i] && rawtext[i] <= 0x77) && (0x21 <= rawtext[i + 1] && rawtext[i + 1] <= 0x77))
  318. {
  319. hzchars += 2;
  320. row = rawtext[i] - 0x21;
  321. column = rawtext[i + 1] - 0x21;
  322. totalfreq += 500;
  323. if (GBFreq[row][column] != 0)
  324. {
  325. hzfreq += GBFreq[row][column];
  326. }
  327. else if (15 <= row && row < 55)
  328. {
  329. hzfreq += 200;
  330. }
  331. }
  332. else if (((byte)0xA1 <= rawtext[i] && rawtext[i] <= (byte)0xF7) && ((byte)0xA1 <= rawtext[i + 1] && rawtext[i + 1] <= (byte)0xF7))
  333. {
  334. hzchars += 2;
  335. row = rawtext[i] + 256 - 0xA1;
  336. column = rawtext[i + 1] + 256 - 0xA1;
  337. totalfreq += 500;
  338. if (GBFreq[row][column] != 0)
  339. {
  340. hzfreq += GBFreq[row][column];
  341. }
  342. else if (15 <= row && row < 55)
  343. {
  344. hzfreq += 200;
  345. }
  346. }
  347. dbchars += 2;
  348. i += 2;
  349. }
  350. }
  351. else if (rawtext[i + 1] == '}')
  352. {
  353. hzend++;
  354. i++;
  355. }
  356. else if (rawtext[i + 1] == '~')
  357. {
  358. i++;
  359. }
  360. }
  361. }
  362. if (hzstart > 4)
  363. {
  364. rangeval = 50;
  365. }
  366. else if (hzstart > 1)
  367. {
  368. rangeval = 41;
  369. }
  370. else if (hzstart > 0)
  371. {
  372. // Only 39 in case the sequence happened to occur
  373. rangeval = 39; // in otherwise non-Hz text
  374. }
  375. else
  376. {
  377. rangeval = 0;
  378. }
  379. freqval = 50 * ((float)hzfreq / (float)totalfreq);
  380. return (int)(rangeval + freqval);
  381. }
  382. #endregion
  383. #region BIG5Probability.....
  384. /// <summary>
  385. /// 判断是BIG5编码的可能性
  386. /// </summary>
  387. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  388. /// <returns>返回 0 至 100 之间的可能性</returns>
  389. internal virtual int BIG5Probability(sbyte[] rawtext)
  390. {
  391. int i, rawtextlen = 0;
  392. int dbchars = 1, bfchars = 1;
  393. float rangeval = 0, freqval = 0;
  394. long bffreq = 0, totalfreq = 1;
  395. int row, column;
  396. // Check to see if characters fit into acceptable ranges
  397. rawtextlen = rawtext.Length;
  398. for (i = 0; i < rawtextlen - 1; i++)
  399. {
  400. if (rawtext[i] >= 0)
  401. {
  402. //asciichars++;
  403. }
  404. else
  405. {
  406. dbchars++;
  407. if ((sbyte)Identity(0xA1) <= rawtext[i] && rawtext[i] <= (sbyte)Identity(0xF9) && (((sbyte)0x40 <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)0x7E) || ((sbyte)Identity(0xA1) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xFE))))
  408. {
  409. bfchars++;
  410. totalfreq += 500;
  411. row = rawtext[i] + 256 - 0xA1;
  412. if (0x40 <= rawtext[i + 1] && rawtext[i + 1] <= 0x7E)
  413. {
  414. column = rawtext[i + 1] - 0x40;
  415. }
  416. else
  417. {
  418. column = rawtext[i + 1] + 256 - 0x61;
  419. }
  420. if (Big5Freq[row][column] != 0)
  421. {
  422. bffreq += Big5Freq[row][column];
  423. }
  424. else if (3 <= row && row <= 37)
  425. {
  426. bffreq += 200;
  427. }
  428. }
  429. i++;
  430. }
  431. }
  432. rangeval = 50 * ((float)bfchars / (float)dbchars);
  433. freqval = 50 * ((float)bffreq / (float)totalfreq);
  434. return (int)(rangeval + freqval);
  435. }
  436. #endregion
  437. #region ENCTWProbability.....
  438. /// <summary>
  439. /// 判断是CNS11643(台湾)编码的可能性
  440. /// </summary>
  441. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  442. /// <returns>返回 0 至 100 之间的可能性</returns>
  443. internal virtual int ENCTWProbability(sbyte[] rawtext)
  444. {
  445. int i, rawtextlen = 0;
  446. int dbchars = 1, cnschars = 1;
  447. long cnsfreq = 0, totalfreq = 1;
  448. float rangeval = 0, freqval = 0;
  449. int row, column;
  450. // Check to see if characters fit into acceptable ranges
  451. // and have expected frequency of use
  452. rawtextlen = rawtext.Length;
  453. for (i = 0; i < rawtextlen - 1; i++)
  454. {
  455. if (rawtext[i] >= 0)
  456. {
  457. // in ASCII range
  458. //asciichars++;
  459. }
  460. else
  461. {
  462. // high bit set
  463. dbchars++;
  464. if (i + 3 < rawtextlen && (sbyte)Identity(0x8E) == rawtext[i] && (sbyte)Identity(0xA1) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xB0) && (sbyte)Identity(0xA1) <= rawtext[i + 2] && rawtext[i + 2] <= (sbyte)Identity(0xFE) && (sbyte)Identity(0xA1) <= rawtext[i + 3] && rawtext[i + 3] <= (sbyte)Identity(0xFE))
  465. {
  466. // Planes 1 - 16
  467. cnschars++;
  468. // These are all less frequent chars so just ignore freq
  469. i += 3;
  470. }
  471. else if ((sbyte)Identity(0xA1) <= rawtext[i] && rawtext[i] <= (sbyte)Identity(0xFE) && (sbyte)Identity(0xA1) <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)Identity(0xFE))
  472. {
  473. cnschars++;
  474. totalfreq += 500;
  475. row = rawtext[i] + 256 - 0xA1;
  476. column = rawtext[i + 1] + 256 - 0xA1;
  477. if (EUC_TWFreq[row][column] != 0)
  478. {
  479. cnsfreq += EUC_TWFreq[row][column];
  480. }
  481. else if (35 <= row && row <= 92)
  482. {
  483. cnsfreq += 150;
  484. }
  485. i++;
  486. }
  487. }
  488. }
  489. rangeval = 50 * ((float)cnschars / (float)dbchars);
  490. freqval = 50 * ((float)cnsfreq / (float)totalfreq);
  491. return (int)(rangeval + freqval);
  492. }
  493. #endregion
  494. #region ISO2022CNProbability.....
  495. /// <summary>
  496. /// 判断是ISO2022CN编码的可能性
  497. /// </summary>
  498. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  499. /// <returns>返回 0 至 100 之间的可能性</returns>
  500. internal virtual int ISO2022CNProbability(sbyte[] rawtext)
  501. {
  502. int i, rawtextlen = 0;
  503. int dbchars = 1, isochars = 1;
  504. long isofreq = 0, totalfreq = 1;
  505. float rangeval = 0, freqval = 0;
  506. int row, column;
  507. // Check to see if characters fit into acceptable ranges
  508. // and have expected frequency of use
  509. rawtextlen = rawtext.Length;
  510. for (i = 0; i < rawtextlen - 1; i++)
  511. {
  512. if (rawtext[i] == (sbyte)0x1B && i + 3 < rawtextlen)
  513. {
  514. // Escape char ESC
  515. if (rawtext[i + 1] == (sbyte)0x24 && rawtext[i + 2] == 0x29 && rawtext[i + 3] == (sbyte)0x41)
  516. {
  517. // GB Escape $ ) A
  518. i += 4;
  519. while (rawtext[i] != (sbyte)0x1B)
  520. {
  521. dbchars++;
  522. if ((0x21 <= rawtext[i] && rawtext[i] <= 0x77) && (0x21 <= rawtext[i + 1] && rawtext[i + 1] <= 0x77))
  523. {
  524. isochars++;
  525. row = rawtext[i] - 0x21;
  526. column = rawtext[i + 1] - 0x21;
  527. totalfreq += 500;
  528. if (GBFreq[row][column] != 0)
  529. {
  530. isofreq += GBFreq[row][column];
  531. }
  532. else if (15 <= row && row < 55)
  533. {
  534. isofreq += 200;
  535. }
  536. i++;
  537. }
  538. i++;
  539. }
  540. }
  541. else if (i + 3 < rawtextlen && rawtext[i + 1] == (sbyte)0x24 && rawtext[i + 2] == (sbyte)0x29 && rawtext[i + 3] == (sbyte)0x47)
  542. {
  543. // CNS Escape $ ) G
  544. i += 4;
  545. while (rawtext[i] != (sbyte)0x1B)
  546. {
  547. dbchars++;
  548. if ((sbyte)0x21 <= rawtext[i] && rawtext[i] <= (sbyte)0x7E && (sbyte)0x21 <= rawtext[i + 1] && rawtext[i + 1] <= (sbyte)0x7E)
  549. {
  550. isochars++;
  551. totalfreq += 500;
  552. row = rawtext[i] - 0x21;
  553. column = rawtext[i + 1] - 0x21;
  554. if (EUC_TWFreq[row][column] != 0)
  555. {
  556. isofreq += EUC_TWFreq[row][column];
  557. }
  558. else if (35 <= row && row <= 92)
  559. {
  560. isofreq += 150;
  561. }
  562. i++;
  563. }
  564. i++;
  565. }
  566. }
  567. if (rawtext[i] == (sbyte)0x1B && i + 2 < rawtextlen && rawtext[i + 1] == (sbyte)0x28 && rawtext[i + 2] == (sbyte)0x42)
  568. {
  569. // ASCII: ESC ( B
  570. i += 2;
  571. }
  572. }
  573. }
  574. rangeval = 50 * ((float)isochars / (float)dbchars);
  575. freqval = 50 * ((float)isofreq / (float)totalfreq);
  576. return (int)(rangeval + freqval);
  577. }
  578. #endregion
  579. #region UTF8Probability.....
  580. /// <summary>
  581. /// 判断是UTF8编码的可能性
  582. /// </summary>
  583. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  584. /// <returns>返回 0 至 100 之间的可能性</returns>
  585. internal virtual int UTF8Probability(sbyte[] rawtext)
  586. {
  587. int score = 0;
  588. int i, rawtextlen = 0;
  589. int goodbytes = 0, asciibytes = 0;
  590. // Maybe also use UTF8 Byte Order Mark: EF BB BF
  591. // Check to see if characters fit into acceptable ranges
  592. rawtextlen = rawtext.Length;
  593. for (i = 0; i < rawtextlen; i++)
  594. {
  595. if ((rawtext[i] & (sbyte)0x7F) == rawtext[i])
  596. {
  597. // One byte
  598. asciibytes++;
  599. // Ignore ASCII, can throw off count
  600. }
  601. else if (-64 <= rawtext[i] && rawtext[i] <= -33 && i + 1 < rawtextlen && -128 <= rawtext[i + 1] && rawtext[i + 1] <= -65)
  602. {
  603. goodbytes += 2;
  604. i++;
  605. }
  606. else if (-32 <= rawtext[i] && rawtext[i] <= -17 && i + 2 < rawtextlen && -128 <= rawtext[i + 1] && rawtext[i + 1] <= -65 && -128 <= rawtext[i + 2] && rawtext[i + 2] <= -65)
  607. {
  608. goodbytes += 3;
  609. i += 2;
  610. }
  611. }
  612. if (asciibytes == rawtextlen)
  613. {
  614. return 0;
  615. }
  616. score = (int)(100 * ((float)goodbytes / (float)(rawtextlen - asciibytes)));
  617. // If not above 98, reduce to zero to prevent coincidental matches
  618. // Allows for some (few) bad formed sequences
  619. if (score > 98)
  620. {
  621. return score;
  622. }
  623. else if (score > 95 && goodbytes > 30)
  624. {
  625. return score;
  626. }
  627. else
  628. {
  629. return 0;
  630. }
  631. }
  632. #endregion
  633. #region UnicodeProbability.....
  634. /// <summary>
  635. /// 判断是Unicode编码的可能性
  636. /// </summary>
  637. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  638. /// <returns>返回 0 至 100 之间的可能性</returns>
  639. internal virtual int UnicodeProbability(sbyte[] rawtext)
  640. {
  641. //int score = 0;
  642. //int i, rawtextlen = 0;
  643. //int goodbytes = 0, asciibytes = 0;
  644. if (((sbyte)Identity(0xFE) == rawtext[0] && (sbyte)Identity(0xFF) == rawtext[1]) || ((sbyte)Identity(0xFF) == rawtext[0] && (sbyte)Identity(0xFE) == rawtext[1]))
  645. {
  646. return 100;
  647. }
  648. return 0;
  649. }
  650. #endregion
  651. #region ASCIIProbability.....
  652. /// <summary>
  653. /// 判断是ASCII编码的可能性
  654. /// </summary>
  655. /// <param name="rawtext">要判断的 <see cref="sbyte"/> 字节数组</param>
  656. /// <returns>返回 0 至 100 之间的可能性</returns>
  657. internal virtual int ASCIIProbability(sbyte[] rawtext)
  658. {
  659. int score = 70;
  660. int i, rawtextlen;
  661. rawtextlen = rawtext.Length;
  662. for (i = 0; i < rawtextlen; i++)
  663. {
  664. if (rawtext[i] < 0)
  665. {
  666. score = score - 5;
  667. }
  668. else if (rawtext[i] == (sbyte)0x1B)
  669. {
  670. // ESC (used by ISO 2022)
  671. score = score - 5;
  672. }
  673. }
  674. return score;
  675. }
  676. #endregion
  677. #endregion
  678. #region Initialize_Frequencies.....
  679. /// <summary>
  680. /// 初始化必要的条件
  681. /// </summary>
  682. internal virtual void Initialize_Frequencies()
  683. {
  684. int i;
  685. if (GBFreq[0] == null)
  686. {
  687. for (i = 0; i < 94; i++)
  688. {
  689. GBFreq[i] = new int[94];
  690. }
  691. #region GBFreq[20][35] = 599;
  692. GBFreq[49][26] = 598;
  693. GBFreq[41][38] = 597;
  694. GBFreq[17][26] = 596;
  695. GBFreq[32][42] = 595;
  696. GBFreq[39][42] = 594;
  697. GBFreq[45][49] = 593;
  698. GBFreq[51][57] = 592;
  699. GBFreq[50][47] = 591;
  700. GBFreq[42][90] = 590;
  701. GBFreq[52][65] = 589;
  702. GBFreq[53][47] = 588;
  703. GBFreq[19][82] = 587;
  704. GBFreq[31][19] = 586;
  705. GBFreq[40][46] = 585;
  706. GBFreq[24][89] = 584;
  707. GBFreq[23][85] = 583;
  708. GBFreq[20][28] = 582;
  709. GBFreq[42][20] = 581;
  710. GBFreq[34][38] = 580;
  711. GBFreq[45][9] = 579;
  712. GBFreq[54][50] = 578;
  713. GBFreq[25][44] = 577;
  714. GBFreq[35][66] = 576;
  715. GBFreq[20][55] = 575;
  716. GBFreq[18][85] = 574;
  717. GBFreq[20][31] = 573;
  718. GBFreq[49][17] = 572;
  719. GBFreq[41][16] = 571;
  720. GBFreq[35][73] = 570;
  721. GBFreq[20][34] = 569;
  722. GBFreq[29][44] = 568;
  723. GBFreq[35][38] = 567;
  724. GBFreq[49][9] = 566;
  725. GBFreq[46][33] = 565;
  726. GBFreq[49][51] = 564;
  727. GBFreq[40][89] = 563;
  728. GBFreq[26][64] = 562;
  729. GBFreq[54][51] = 561;
  730. GBFreq[54][36] = 560;
  731. GBFreq[39][4] = 559;
  732. GBFreq[53][13] = 558;
  733. GBFreq[24][92] = 557;
  734. GBFreq[27][49] = 556;
  735. GBFreq[48][6] = 555;
  736. GBFreq[21][51] = 554;
  737. GBFreq[30][40] = 553;
  738. GBFreq[42][92] = 552;
  739. GBFreq[31][78] = 551;
  740. GBFreq[25][82] = 550;
  741. GBFreq[47][0] = 549;
  742. GBFreq[34][19] = 548;
  743. GBFreq[47][35] = 547;
  744. GBFreq[21][63] = 546;
  745. GBFreq[43][75] = 545;
  746. GBFreq[21][87] = 544;
  747. GBFreq[35][59] = 543;
  748. GBFreq[25][34] = 542;
  749. GBFreq[21][27] = 541;
  750. GBFreq[39][26] = 540;
  751. GBFreq[34][26] = 539;
  752. GBFreq[39][52] = 538;
  753. GBFreq[50][57] = 537;
  754. GBFreq[37][79] = 536;
  755. GBFreq[26][24] = 535;
  756. GBFreq[22][1] = 534;
  757. GBFreq[18][40] = 533;
  758. GBFreq[41][33] = 532;
  759. GBFreq[53][26] = 531;
  760. GBFreq[54][86] = 530;
  761. GBFreq[20][16] = 529;
  762. GBFreq[46][74] = 528;
  763. GBFreq[30][19] = 527;
  764. GBFreq[45][35] = 526;
  765. GBFreq[45][61] = 525;
  766. GBFreq[30][9] = 524;
  767. GBFreq[41][53] = 523;
  768. GBFreq[41][13] = 522;
  769. GBFreq[50][34] = 521;
  770. GBFreq[53][86] = 520;
  771. GBFreq[47][47] = 519;
  772. GBFreq[22][28] = 518;
  773. GBFreq[50][53] = 517;
  774. GBFreq[39][70] = 516;
  775. GBFreq[38][15] = 515;
  776. GBFreq[42][88] = 514;
  777. GBFreq[16][29] = 513;
  778. GBFreq[27][90] = 512;
  779. GBFreq[29][12] = 511;
  780. GBFreq[44][22] = 510;
  781. GBFreq[34][69] = 509;
  782. GBFreq[24][10] = 508;
  783. GBFreq[44][11] = 507;
  784. GBFreq[39][92] = 506;
  785. GBFreq[49][48] = 505;
  786. GBFreq[31][46] = 504;
  787. GBFreq[19][50] = 503;
  788. GBFreq[21][14] = 502;
  789. GBFreq[32][28] = 501;
  790. GBFreq[18][3] = 500;
  791. GBFreq[53][9] = 499;
  792. GBFreq[34][80] = 498;
  793. GBFreq[48][88] = 497;
  794. GBFreq[46][53] = 496;
  795. GBFreq[22][53] = 495;
  796. GBFreq[28][10] = 494;
  797. GBFreq[44][65] = 493;
  798. GBFreq[20][10] = 492;
  799. GBFreq[40][76] = 491;
  800. GBFreq[47][8] = 490;
  801. GBFreq[50][74] = 489;
  802. GBFreq[23][62] = 488;
  803. GBFreq[49][65] = 487;
  804. GBFreq[28][87] = 486;
  805. GBFreq[15][48] = 485;
  806. GBFreq[22][7] = 484;
  807. GBFreq[19][42] = 483;
  808. GBFreq[41][20] = 482;
  809. GBFreq[26][55] = 481;
  810. GBFreq[21][93] = 480;
  811. GBFreq[31][76] = 479;
  812. GBFreq[34][31] = 478;
  813. GBFreq[20][66] = 477;
  814. GBFreq[51][33] = 476;
  815. GBFreq[34][86] = 475;
  816. GBFreq[37][67] = 474;
  817. GBFreq[53][53] = 473;
  818. GBFreq[40][88] = 472;
  819. GBFreq[39][10] = 471;
  820. GBFreq[24][3] = 470;
  821. GBFreq[27][25] = 469;
  822. GBFreq[26][15] = 468;
  823. GBFreq[21][88] = 467;
  824. GBFreq[52][62] = 466;
  825. GBFreq[46][81] = 465;
  826. GBFreq[38][72] = 464;
  827. GBFreq[17][30] = 463;
  828. GBFreq[52][92] = 462;
  829. GBFreq[34][90] = 461;
  830. GBFreq[21][7] = 460;
  831. GBFreq[36][13] = 459;
  832. GBFreq[45][41] = 458;
  833. GBFreq[32][5] = 457;
  834. GBFreq[26][89] = 456;
  835. GBFreq[23][87] = 455;
  836. GBFreq[20][39] = 454;
  837. GBFreq[27][23] = 453;
  838. GBFreq[25][59] = 452;
  839. GBFreq[49][20] = 451;
  840. GBFreq[54][77] = 450;
  841. GBFreq[27][67] = 449;
  842. GBFreq[47][33] = 448;
  843. GBFreq[41][17] = 447;
  844. GBFreq[19][81] = 446;
  845. GBFreq[16][66] = 445;
  846. GBFreq[45][26] = 444;
  847. GBFreq[49][81] = 443;
  848. GBFreq[53][55] = 442;
  849. GBFreq[16][26] = 441;
  850. GBFreq[54][62] = 440;
  851. GBFreq[20][70] = 439;
  852. GBFreq[42][35] = 438;
  853. GBFreq[20][57] = 437;
  854. GBFreq[34][36] = 436;
  855. GBFreq[46][63] = 435;
  856. GBFreq[19][45] = 434;
  857. GBFreq[21][10] = 433;
  858. GBFreq[52][93] = 432;
  859. GBFreq[25][2] = 431;
  860. GBFreq[30][57] = 430;
  861. GBFreq[41][24] = 429;
  862. GBFreq[28][43] = 428;
  863. GBFreq[45][86] = 427;
  864. GBFreq[51][56] = 426;
  865. GBFreq[37][28] = 425;
  866. GBFreq[52][69] = 424;
  867. GBFreq[43][92] = 423;
  868. GBFreq[41][31] = 422;
  869. GBFreq[37][87] = 421;
  870. GBFreq[47][36] = 420;
  871. GBFreq[16][16] = 419;
  872. GBFreq[40][56] = 418;
  873. GBFreq[24][55] = 417;
  874. GBFreq[17][1] = 416;
  875. GBFreq[35][57] = 415;
  876. GBFreq[27][50] = 414;
  877. GBFreq[26][14] = 413;
  878. GBFreq[50][40] = 412;
  879. GBFreq[39][19] = 411;
  880. GBFreq[19][89] = 410;
  881. GBFreq[29][91] = 409;
  882. GBFreq[17][89] = 408;
  883. GBFreq[39][74] = 407;
  884. GBFreq[46][39] = 406;
  885. GBFreq[40][28] = 405;
  886. GBFreq[45][68] = 404;
  887. GBFreq[43][10] = 403;
  888. GBFreq[42][13] = 402;
  889. GBFreq[44][81] = 401;
  890. GBFreq[41][47] = 400;
  891. GBFreq[48][58] = 399;
  892. GBFreq[43][68] = 398;
  893. GBFreq[16][79] = 397;
  894. GBFreq[19][5] = 396;
  895. GBFreq[54][59] = 395;
  896. GBFreq[17][36] = 394;
  897. GBFreq[18][0] = 393;
  898. GBFreq[41][5] = 392;
  899. GBFreq[41][72] = 391;
  900. GBFreq[16][39] = 390;
  901. GBFreq[54][0] = 389;
  902. GBFreq[51][16] = 388;
  903. GBFreq[29][36] = 387;
  904. GBFreq[47][5] = 386;
  905. GBFreq[47][51] = 385;
  906. GBFreq[44][7] = 384;
  907. GBFreq[35][30] = 383;
  908. GBFreq[26][9] = 382;
  909. GBFreq[16][7] = 381;
  910. GBFreq[32][1] = 380;
  911. GBFreq[33][76] = 379;
  912. GBFreq[34][91] = 378;
  913. GBFreq[52][36] = 377;
  914. GBFreq[26][77] = 376;
  915. GBFreq[35][48] = 375;
  916. GBFreq[40][80] = 374;
  917. GBFreq[41][92] = 373;
  918. GBFreq[27][93] = 372;
  919. GBFreq[15][17] = 371;
  920. GBFreq[16][76] = 370;
  921. GBFreq[51][12] = 369;
  922. GBFreq[18][20] = 368;
  923. GBFreq[15][54] = 367;
  924. GBFreq[50][5] = 366;
  925. GBFreq[33][22] = 365;
  926. GBFreq[37][57] = 364;
  927. GBFreq[28][47] = 363;
  928. GBFreq[42][31] = 362;
  929. GBFreq[18][2] = 361;
  930. GBFreq[43][64] = 360;
  931. GBFreq[23][47] = 359;
  932. GBFreq[28][79] = 358;
  933. GBFreq[25][45] = 357;
  934. GBFreq[23][91] = 356;
  935. GBFreq[22][19] = 355;
  936. GBFreq[25][46] = 354;
  937. GBFreq[22][36] = 353;
  938. GBFreq[54][85] = 352;
  939. GBFreq[46][20] = 351;
  940. GBFreq[27][37] = 350;
  941. GBFreq[26][81] = 349;
  942. GBFreq[42][29] = 348;
  943. GBFreq[31][90] = 347;
  944. GBFreq[41][59] = 346;
  945. GBFreq[24][65] = 345;
  946. GBFreq[44][84] = 344;
  947. GBFreq[24][90] = 343;
  948. GBFreq[38][54] = 342;
  949. GBFreq[28][70] = 341;
  950. GBFreq[27][15] = 340;
  951. GBFreq[28][80] = 339;
  952. GBFreq[29][8] = 338;
  953. GBFreq[45][80] = 337;
  954. GBFreq[53][37] = 336;
  955. GBFreq[28][65] = 335;
  956. GBFreq[23][86] = 334;
  957. GBFreq[39][45] = 333;
  958. GBFreq[53][32] = 332;
  959. GBFreq[38][68] = 331;
  960. GBFreq[45][78] = 330;
  961. GBFreq[43][7] = 329;
  962. GBFreq[46][82] = 328;
  963. GBFreq[27][38] = 327;
  964. GBFreq[16][62] = 326;
  965. GBFreq[24][17] = 325;
  966. GBFreq[22][70] = 324;
  967. GBFreq[52][28] = 323;
  968. GBFreq[23][40] = 322;
  969. GBFreq[28][50] = 321;
  970. GBFreq[42][91] = 320;
  971. GBFreq[47][76] = 319;
  972. GBFreq[15][42] = 318;
  973. GBFreq[43][55] = 317;
  974. GBFreq[29][84] = 316;
  975. GBFreq[44][90] = 315;
  976. GBFreq[53][16] = 314;
  977. GBFreq[22][93] = 313;
  978. GBFreq[34][10] = 312;
  979. GBFreq[32][53] = 311;
  980. GBFreq[43][65] = 310;
  981. GBFreq[28][7] = 309;
  982. GBFreq[35][46] = 308;
  983. GBFreq[21][39] = 307;
  984. GBFreq[44][18] = 306;
  985. GBFreq[40][10] = 305;
  986. GBFreq[54][53] = 304;
  987. GBFreq[38][74] = 303;
  988. GBFreq[28][26] = 302;
  989. GBFreq[15][13] = 301;
  990. GBFreq[39][34] = 300;
  991. GBFreq[39][46] = 299;
  992. GBFreq[42][66] = 298;
  993. GBFreq[33][58] = 297;
  994. GBFreq[15][56] = 296;
  995. GBFreq[18][51] = 295;
  996. GBFreq[49][68] = 294;
  997. GBFreq[30][37] = 293;
  998. GBFreq[51][84] = 292;
  999. GBFreq[51][9] = 291;
  1000. GBFreq[40][70] = 290;
  1001. GBFreq[41][84] = 289;
  1002. GBFreq[28][64] = 288;
  1003. GBFreq[32][88] = 287;
  1004. GBFreq[24][5] = 286;
  1005. GBFreq[53][23] = 285;
  1006. GBFreq[42][27] = 284;
  1007. GBFreq[22][38] = 283;
  1008. GBFreq[32][86] = 282;
  1009. GBFreq[34][30] = 281;
  1010. GBFreq[38][63] = 280;
  1011. GBFreq[24][59] = 279;
  1012. GBFreq[22][81] = 278;
  1013. GBFreq[32][11] = 277;
  1014. GBFreq[51][21] = 276;
  1015. GBFreq[54][41] = 275;
  1016. GBFreq[21][50] = 274;
  1017. GBFreq[23][89] = 273;
  1018. GBFreq[19][87] = 272;
  1019. GBFreq[26][7] = 271;
  1020. GBFreq[30][75] = 270;
  1021. GBFreq[43][84] = 269;
  1022. GBFreq[51][25] = 268;
  1023. GBFreq[16][67] = 267;
  1024. GBFreq[32][9] = 266;
  1025. GBFreq[48][51] = 265;
  1026. GBFreq[39][7] = 264;
  1027. GBFreq[44][88] = 263;
  1028. GBFreq[52][24] = 262;
  1029. GBFreq[23][34] = 261;
  1030. GBFreq[32][75] = 260;
  1031. GBFreq[19][10] = 259;
  1032. GBFreq[28][91] = 258;
  1033. GBFreq[32][83] = 257;
  1034. GBFreq[25][75] = 256;
  1035. GBFreq[53][45] = 255;
  1036. GBFreq[29][85] = 254;
  1037. GBFreq[53][59] = 253;
  1038. GBFreq[16][2] = 252;
  1039. GBFreq[19][78] = 251;
  1040. GBFreq[15][75] = 250;
  1041. GBFreq[51][42] = 249;
  1042. GBFreq[45][67] = 248;
  1043. GBFreq[15][74] = 247;
  1044. GBFreq[25][81] = 246;
  1045. GBFreq[37][62] = 245;
  1046. GBFreq[16][55] = 244;
  1047. GBFreq[18][38] = 243;
  1048. GBFreq[23][23] = 242;
  1049. GBFreq[38][30] = 241;
  1050. GBFreq[17][28] = 240;
  1051. GBFreq[44][73] = 239;
  1052. GBFreq[23][78] = 238;
  1053. GBFreq[40][77] = 237;
  1054. GBFreq[38][87] = 236;
  1055. GBFreq[27][19] = 235;
  1056. GBFreq[38][82] = 234;
  1057. GBFreq[37][22] = 233;
  1058. GBFreq[41][30] = 232;
  1059. GBFreq[54][9] = 231;
  1060. GBFreq[32][30] = 230;
  1061. GBFreq[30][52] = 229;
  1062. GBFreq[40][84] = 228;
  1063. GBFreq[53][57] = 227;
  1064. GBFreq[27][27] = 226;
  1065. GBFreq[38][64] = 225;
  1066. GBFreq[18][43] = 224;
  1067. GBFreq[23][69] = 223;
  1068. GBFreq[28][12] = 222;
  1069. GBFreq[50][78] = 221;
  1070. GBFreq[50][1] = 220;
  1071. GBFreq[26][88] = 219;
  1072. GBFreq[36][40] = 218;
  1073. GBFreq[33][89] = 217;
  1074. GBFreq[41][28] = 216;
  1075. GBFreq[31][77] = 215;
  1076. GBFreq[46][1] = 214;
  1077. GBFreq[47][19] = 213;
  1078. GBFreq[35][55] = 212;
  1079. GBFreq[41][21] = 211;
  1080. GBFreq[27][10] = 210;
  1081. GBFreq[32][77] = 209;
  1082. GBFreq[26][37] = 208;
  1083. GBFreq[20][33] = 207;
  1084. GBFreq[41][52] = 206;
  1085. GBFreq[32][18] = 205;
  1086. GBFreq[38][13] = 204;
  1087. GBFreq[20][18] = 203;
  1088. GBFreq[20][24] = 202;
  1089. GBFreq[45][19] = 201;
  1090. GBFreq[18][53] = 200;
  1091. #endregion
  1092. }
  1093. if (GBKFreq[0] == null)
  1094. {
  1095. for (i = 0; i < 126; i++)
  1096. {
  1097. GBKFreq[i] = new int[191];
  1098. }
  1099. #region GBKFreq[52][132] = 600;
  1100. GBKFreq[73][135] = 599;
  1101. GBKFreq[49][123] = 598;
  1102. GBKFreq[77][146] = 597;
  1103. GBKFreq[81][123] = 596;
  1104. GBKFreq[82][144] = 595;
  1105. GBKFreq[51][179] = 594;
  1106. GBKFreq[83][154] = 593;
  1107. GBKFreq[71][139] = 592;
  1108. GBKFreq[64][139] = 591;
  1109. GBKFreq[85][144] = 590;
  1110. GBKFreq[52][125] = 589;
  1111. GBKFreq[88][25] = 588;
  1112. GBKFreq[81][106] = 587;
  1113. GBKFreq[81][148] = 586;
  1114. GBKFreq[62][137] = 585;
  1115. GBKFreq[94][0] = 584;
  1116. GBKFreq[1][64] = 583;
  1117. GBKFreq[67][163] = 582;
  1118. GBKFreq[20][190] = 581;
  1119. GBKFreq[57][131] = 580;
  1120. GBKFreq[29][169] = 579;
  1121. GBKFreq[72][143] = 578;
  1122. GBKFreq[0][173] = 577;
  1123. GBKFreq[11][23] = 576;
  1124. GBKFreq[61][141] = 575;
  1125. GBKFreq[60][123] = 574;
  1126. GBKFreq[81][114] = 573;
  1127. GBKFreq[82][131] = 572;
  1128. GBKFreq[67][156] = 571;
  1129. GBKFreq[71][167] = 570;
  1130. GBKFreq[20][50] = 569;
  1131. GBKFreq[77][132] = 568;
  1132. GBKFreq[84][38] = 567;
  1133. GBKFreq[26][29] = 566;
  1134. GBKFreq[74][187] = 565;
  1135. GBKFreq[62][116] = 564;
  1136. GBKFreq[67][135] = 563;
  1137. GBKFreq[5][86] = 562;
  1138. GBKFreq[72][186] = 561;
  1139. GBKFreq[75][161] = 560;
  1140. GBKFreq[78][130] = 559;
  1141. GBKFreq[94][30] = 558;
  1142. GBKFreq[84][72] = 557;
  1143. GBKFreq[1][67] = 556;
  1144. GBKFreq[75][172] = 555;
  1145. GBKFreq[74][185] = 554;
  1146. GBKFreq[53][160] = 553;
  1147. GBKFreq[123][14] = 552;
  1148. GBKFreq[79][97] = 551;
  1149. GBKFreq[85][110] = 550;
  1150. GBKFreq[78][171] = 549;
  1151. GBKFreq[52][131] = 548;
  1152. GBKFreq[56][100] = 547;
  1153. GBKFreq[50][182] = 546;
  1154. GBKFreq[94][64] = 545;
  1155. GBKFreq[106][74] = 544;
  1156. GBKFreq[11][102] = 543;
  1157. GBKFreq[53][124] = 542;
  1158. GBKFreq[24][3] = 541;
  1159. GBKFreq[86][148] = 540;
  1160. GBKFreq[53][184] = 539;
  1161. GBKFreq[86][147] = 538;
  1162. GBKFreq[96][161] = 537;
  1163. GBKFreq[82][77] = 536;
  1164. GBKFreq[59][146] = 535;
  1165. GBKFreq[84][126] = 534;
  1166. GBKFreq[79][132] = 533;
  1167. GBKFreq[85][123] = 532;
  1168. GBKFreq[71][101] = 531;
  1169. GBKFreq[85][106] = 530;
  1170. GBKFreq[6][184] = 529;
  1171. GBKFreq[57][156] = 528;
  1172. GBKFreq[75][104] = 527;
  1173. GBKFreq[50][137] = 526;
  1174. GBKFreq[79][133] = 525;
  1175. GBKFreq[76][108] = 524;
  1176. GBKFreq[57][142] = 523;
  1177. GBKFreq[84][130] = 522;
  1178. GBKFreq[52][128] = 521;
  1179. GBKFreq[47][44] = 520;
  1180. GBKFreq[52][152] = 519;
  1181. GBKFreq[54][104] = 518;
  1182. GBKFreq[30][47] = 517;
  1183. GBKFreq[71][123] = 516;
  1184. GBKFreq[52][107] = 515;
  1185. GBKFreq[45][84] = 514;
  1186. GBKFreq[107][118] = 513;
  1187. GBKFreq[5][161] = 512;
  1188. GBKFreq[48][126] = 511;
  1189. GBKFreq[67][170] = 510;
  1190. GBKFreq[43][6] = 509;
  1191. GBKFreq[70][112] = 508;
  1192. GBKFreq[86][174] = 507;
  1193. GBKFreq[84][166] = 506;
  1194. GBKFreq[79][130] = 505;
  1195. GBKFreq[57][141] = 504;
  1196. GBKFreq[81][178] = 503;
  1197. GBKFreq[56][187] = 502;
  1198. GBKFreq[81][162] = 501;
  1199. GBKFreq[53][104] = 500;
  1200. GBKFreq[123][35] = 499;
  1201. GBKFreq[70][169] = 498;
  1202. GBKFreq[69][164] = 497;
  1203. GBKFreq[109][61] = 496;
  1204. GBKFreq[73][130] = 495;
  1205. GBKFreq[62][134] = 494;
  1206. GBKFreq[54][125] = 493;
  1207. GBKFreq[79][105] = 492;
  1208. GBKFreq[70][165] = 491;
  1209. GBKFreq[71][189] = 490;
  1210. GBKFreq[23][147] = 489;
  1211. GBKFreq[51][139] = 48

Large files files are truncated, but you can click here to view the full file