From 9cd78407f0402d7408dee4da7a5c405141579a32 Mon Sep 17 00:00:00 2001 From: inoas Date: Sun, 4 Dec 2022 19:54:03 +0100 Subject: tests --- src/gleam/string.gleam | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam index 5369b32..e2377e2 100644 --- a/src/gleam/string.gleam +++ b/src/gleam/string.gleam @@ -900,6 +900,27 @@ pub fn utf_codepoint(value: Int) -> Result(UtfCodepoint, Nil) { } } +/// Converts a string to a list of UtfCodepoint integers. +/// +/// ## Examples +/// +/// ```gleam +/// > "abc" +/// > |> string.to_ints +/// [97, 98, 99] +/// ``` +/// +/// ```gleam +/// > "🐍" +/// > |> string.to_ints +/// [128013] +/// ``` +/// +/// ```gleam +/// > [utf_codepoint(128013)] |> from_utf_codepoints |> to_ints +/// "🐍" +/// ``` +/// pub fn to_ints(s: String) -> List(Int) { to_utf_codepoints(s) |> list.map(utf_codepoint_to_int) -- cgit v1.2.3