This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Re: https://twitter.com/llaisdy/status/1558536851560054786?s=20&t=us8J3LvoJTlwVwod5bOqeQ *) | |
(* Use this if using the REPL, otherwise use dune to build with the library dependency *) | |
#require "uutf";; | |
(* Converts an array of ints (Unicode graphemes) into a UTF-8 encoded string. *) | |
let utf8_to_string uchars = | |
let buf = Buffer.create (2 * Array.length uchars) in | |
Array.iter (fun uchar -> Uutf.Buffer.add_utf_8 buf (Uchar.of_int uchar)) uchars; | |
Buffer.contents buf |