utf8.ml 485 B

12345678910111213
  1. (* wiem że są biblioteki ale dla jaj robie swoje *)
  2. let single_byte_char c = ((int_of_char c) land 0x80) = 0x00
  3. let non_head_char c = ((int_of_char c) land 0xC0) == 0x80
  4. let two_bytes_char c = ((int_of_char c) land 0xE0) == 0xC0
  5. let three_bytes_char c = ((int_of_char c) land 0xF0) == 0xE0
  6. let four_bytes_char c = ((int_of_char c) land 0xF8) == 0xF0
  7. let char_length c =
  8. if single_byte_char c then 1 else
  9. if two_bytes_char c then 2 else
  10. if three_bytes_char c then 3 else
  11. 4