| 190 | |
| 191 | |
| 192 | class SJISDistributionAnalysis(CharDistributionAnalysis): |
| 193 | def __init__(self): |
| 194 | super(SJISDistributionAnalysis, self).__init__() |
| 195 | self._char_to_freq_order = JIS_CHAR_TO_FREQ_ORDER |
| 196 | self._table_size = JIS_TABLE_SIZE |
| 197 | self.typical_distribution_ratio = JIS_TYPICAL_DISTRIBUTION_RATIO |
| 198 | |
| 199 | def get_order(self, byte_str): |
| 200 | # for sjis encoding, we are interested |
| 201 | # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe |
| 202 | # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe |
| 203 | # no validation needed here. State machine has done that |
| 204 | first_char, second_char = byte_str[0], byte_str[1] |
| 205 | if (first_char >= 0x81) and (first_char <= 0x9F): |
| 206 | order = 188 * (first_char - 0x81) |
| 207 | elif (first_char >= 0xE0) and (first_char <= 0xEF): |
| 208 | order = 188 * (first_char - 0xE0 + 31) |
| 209 | else: |
| 210 | return -1 |
| 211 | order = order + second_char - 0x40 |
| 212 | if second_char > 0x7F: |
| 213 | order = -1 |
| 214 | return order |
| 215 | |
| 216 | |
| 217 | class EUCJPDistributionAnalysis(CharDistributionAnalysis): |
no outgoing calls
no test coverage detected
searching dependent graphs…