diff options
author | inoas <mail@inoas.com> | 2022-12-09 09:10:36 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-12-22 20:44:33 +0000 |
commit | 9dc8bc4b3e9b58396ceae3e2bb466c1eb4679f86 (patch) | |
tree | 6f2e022109d024886f789dc6380e36be35d0a94e /src | |
parent | 48f47291d190ce02701a23a431fda9d8dab99ac1 (diff) | |
download | gleam_stdlib-9dc8bc4b3e9b58396ceae3e2bb466c1eb4679f86.tar.gz gleam_stdlib-9dc8bc4b3e9b58396ceae3e2bb466c1eb4679f86.zip |
replace string.to_ints with string.utf_codepoint_to_int
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/string.gleam | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam index e2377e2..04d58a8 100644 --- a/src/gleam/string.gleam +++ b/src/gleam/string.gleam @@ -900,39 +900,26 @@ pub fn utf_codepoint(value: Int) -> Result(UtfCodepoint, Nil) { } } -/// Converts a string to a list of UtfCodepoint integers. +/// Converts an UtfCodepoint to its ordinal code point value. /// /// ## Examples /// /// ```gleam -/// > "abc" -/// > |> string.to_ints -/// [97, 98, 99] +/// > utf_codepoint_to_int(128013) |> to_utf_codepoint_int +/// 128013 /// ``` /// -/// ```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) +pub fn utf_codepoint_to_int(cp: UtfCodepoint) -> Int { + do_utf_codepoint_to_int(cp) } if erlang { - external fn utf_codepoint_to_int(cp: UtfCodepoint) -> Int = + external fn do_utf_codepoint_to_int(cp: UtfCodepoint) -> Int = "gleam_stdlib" "identity" } if javascript { - external fn utf_codepoint_to_int(cp: UtfCodepoint) -> Int = + external fn do_utf_codepoint_to_int(cp: UtfCodepoint) -> Int = "../gleam_stdlib.mjs" "utf_codepoint_to_int" } |