aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClombrong <cromblong@egregore.fun>2025-07-01 11:30:42 +0200
committerClombrong <cromblong@egregore.fun>2025-07-26 21:55:11 +0200
commit664e930172603118f7341f7cfba284db61772876 (patch)
tree2c178d4ee7e13b20e052923043bcc510bce3895c
parent4256e76d7a8cfdb2d6b3afafd281c9fc59e800ec (diff)
feat(jid): add inverse function string_of_uchars
-rw-r--r--lib/jid.ml5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/jid.ml b/lib/jid.ml
index 2ca0795..b06a00c 100644
--- a/lib/jid.ml
+++ b/lib/jid.ml
@@ -24,6 +24,11 @@ let uchars_of_string s : uchars =
loop (u :: acc) (i + k)
in loop [] (String.length s)
+let string_of_uchars (u : uchars) =
+ let buf = Buffer.create (4 * List.length u) in
+ List.iter (Buffer.add_utf_8_uchar buf) u;
+ Buffer.to_bytes buf |> String.of_bytes
+
let of_string (jid : string) : t =
let open Uchar in
let len = String.length jid in