| 149 | |
| 150 | |
| 151 | class GB2312DistributionAnalysis(CharDistributionAnalysis): |
| 152 | def __init__(self): |
| 153 | super(GB2312DistributionAnalysis, self).__init__() |
| 154 | self._char_to_freq_order = GB2312_CHAR_TO_FREQ_ORDER |
| 155 | self._table_size = GB2312_TABLE_SIZE |
| 156 | self.typical_distribution_ratio = GB2312_TYPICAL_DISTRIBUTION_RATIO |
| 157 | |
| 158 | def get_order(self, byte_str): |
| 159 | # for GB2312 encoding, we are interested |
| 160 | # first byte range: 0xb0 -- 0xfe |
| 161 | # second byte range: 0xa1 -- 0xfe |
| 162 | # no validation needed here. State machine has done that |
| 163 | first_char, second_char = byte_str[0], byte_str[1] |
| 164 | if (first_char >= 0xB0) and (second_char >= 0xA1): |
| 165 | return 94 * (first_char - 0xB0) + second_char - 0xA1 |
| 166 | else: |
| 167 | return -1 |
| 168 | |
| 169 | |
| 170 | class Big5DistributionAnalysis(CharDistributionAnalysis): |
no outgoing calls
no test coverage detected
searching dependent graphs…