| 168 | |
| 169 | |
| 170 | class Big5DistributionAnalysis(CharDistributionAnalysis): |
| 171 | def __init__(self): |
| 172 | super(Big5DistributionAnalysis, self).__init__() |
| 173 | self._char_to_freq_order = BIG5_CHAR_TO_FREQ_ORDER |
| 174 | self._table_size = BIG5_TABLE_SIZE |
| 175 | self.typical_distribution_ratio = BIG5_TYPICAL_DISTRIBUTION_RATIO |
| 176 | |
| 177 | def get_order(self, byte_str): |
| 178 | # for big5 encoding, we are interested |
| 179 | # first byte range: 0xa4 -- 0xfe |
| 180 | # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe |
| 181 | # no validation needed here. State machine has done that |
| 182 | first_char, second_char = byte_str[0], byte_str[1] |
| 183 | if first_char >= 0xA4: |
| 184 | if second_char >= 0xA1: |
| 185 | return 157 * (first_char - 0xA4) + second_char - 0xA1 + 63 |
| 186 | else: |
| 187 | return 157 * (first_char - 0xA4) + second_char - 0x40 |
| 188 | else: |
| 189 | return -1 |
| 190 | |
| 191 | |
| 192 | class SJISDistributionAnalysis(CharDistributionAnalysis): |
no outgoing calls
no test coverage detected
searching dependent graphs…