# What's the function of Uchar?

**URL:** <https://discuss.ocaml.org/t/whats-the-function-of-uchar/939>\
**Category:** Learning\
**Created:** [October 9, 2017, 5:07pm UTC](https://discuss.ocaml.org/t/whats-the-function-of-uchar/939 "2017-10-09T17:07:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [October 9, 2017, 5:07pm UTC](https://discuss.ocaml.org/t/whats-the-function-of-uchar/939/1 "2017-10-09T17:07:39Z")

</div>

Howdy! What’s the de facto use case for the Uchar.t type and Uchar module? It doesn’t seem to provide much real functionality. (For example, there’s nothing to turn a Uchar.t into a string of utf8 chars or what have you, nor have I seen something in the standard library that turns a utf8 sequence in a string into a Uchar.t.) I’ve also not noticed it being used elsewhere in the standard library. There’s no printf format character for a Uchar.t.

Is it a matter of it being intended for future use?

---

<div class="post-metadata">

**Author:** ![zozozo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zozozo/32/59_2.png) [@zozozo](https://discuss.ocaml.org/u/zozozo)\
**Post date:** [October 9, 2017, 6:43pm UTC](https://discuss.ocaml.org/t/whats-the-function-of-uchar/939/2 "2017-10-09T18:43:43Z")

</div>

From what I know, the `Uchar` module is intended for compatibility between libraries that manipulate unicode, so that all libraries share the same type for unicode characters (as stated in the documentation of the module).

You might be interested in reading the dicussion that lead to the addition of the module (in the associated [github pull request](https://github.com/ocaml/ocaml/pull/80)).

I personally use the [Uucp](http://erratique.ch/software/uucp) and [Uutf](http://erratique.ch/software/uutf) libraries in my projects, both of which use the `Uchar.t` type.

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)\
**Post date:** [October 9, 2017, 7:13pm UTC](https://discuss.ocaml.org/t/whats-the-function-of-uchar/939/3 "2017-10-09T19:13:40Z")

</div>

Another PR of interest is [this one](https://github.com/ocaml/ocaml/pull/1091) which allows to encode `Uchar.t` values into `Buffer.t` and made it in the upcoming 4.06.

If you are interested in OCaml and Unicode there’s also [this one](https://github.com/ocaml/ocaml/pull/1232) for 4.06 but it’s OT for this thread.

---

<div class="post-metadata">

**Author:** ![perry](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/perry/32/518_2.png) [@perry](https://discuss.ocaml.org/u/perry)\
**Post date:** [October 9, 2017, 8:08pm UTC](https://discuss.ocaml.org/t/whats-the-function-of-uchar/939/4 "2017-10-09T20:08:43Z")

</div>

Thank you, all of those links are quite helpful!

Any chance of printf or similar support showing up? It would be helpful for debugging.
