| 131 | |
| 132 | template <typename octet_difference_type> |
| 133 | inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length) |
| 134 | { |
| 135 | if (cp < 0x80) { |
| 136 | if (length != 1) |
| 137 | return true; |
| 138 | } |
| 139 | else if (cp < 0x800) { |
| 140 | if (length != 2) |
| 141 | return true; |
| 142 | } |
| 143 | else if (cp < 0x10000) { |
| 144 | if (length != 3) |
| 145 | return true; |
| 146 | } |
| 147 | |
| 148 | return false; |
| 149 | } |
| 150 | |
| 151 | enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT}; |
| 152 |