aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/string.gleam27
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"
}