Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does `string` in OCaml support UTF-8?

Does the type string in OCaml support utf8?

Or what library I should use for utf8 string?

like image 789
Jackson Tale Avatar asked Apr 22 '13 16:04

Jackson Tale


People also ask

Does OCaml support unicode?

Yes, because “unicode string” is not really a meaningful concept. You are mixing a container ( string , aka an array of bytes) with a standard for describing human scripts ( unicode ) that can be potentially encoded inside strings with a specific encoding like utf-8 or utf-16 .

What are UTF-8 strings?

UTF-8 is a Unicode character encoding method. This means that UTF-8 takes the code point for a given Unicode character and translates it into a string of binary. It also does the reverse, reading in binary digits and converting them back to characters.

What is an invalid UTF-8 string?

This error is created when the uploaded file is not in a UTF-8 format. UTF-8 is the dominant character encoding format on the World Wide Web. This error occurs because the software you are using saves the file in a different type of encoding, such as ISO-8859, instead of UTF-8.


2 Answers

The string type of OCaml consists of a series of 8-bit bytes in essence. You can store a UTF-8 value in a string, and I have often done this. However, there's no built-in support for handling them. A good library for handling Unicode in OCaml (so I've heard) is Camomile.

like image 189
Jeffrey Scofield Avatar answered Sep 19 '22 17:09

Jeffrey Scofield


There is also Uutf if you're looking for just unicode conversion.

like image 34
Török Edwin Avatar answered Sep 17 '22 17:09

Török Edwin