Skip to content

Commit fa79682

Browse files
committed
fix(string): string:codepoints returns a list of codepoints as numbers
1 parent 13078f0 commit fa79682

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

String.ark

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@
7777
# @author https://github.com/SuperFola
7878
(let utf8len (fun (_str) (builtin__string:utf8len _str)))
7979

80-
# @brief Compute the UTF8 codepoints that makes a string, and return them as a List
80+
# @brief Compute the UTF8 codepoints that makes a string, and return them as a List of numbers
8181
# @param _str String
8282
# =begin
83-
# (print (string:codepoints "abc")) # ["a" "b" "c"]
83+
# (print (string:codepoints "abc")) # [97 98 99]
84+
# # strings can be reassembled from their codepoints:
85+
# (print (string:join (list:map (string:codepoints "🏳️‍⚧️") string:chr) "")) # 🏳️‍⚧️
8486
# =end
8587
# @author https://github.com/SuperFola
8688
(let codepoints (fun (_str) (builtin__string:codepoints _str)))

tests/string-tests.ark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
(test:case "codepoints" {
5656
(test:eq (builtin__string:codepoints "hello") (string:codepoints "hello"))
5757
(test:eq (string:codepoints "") [])
58-
(test:eq (string:codepoints "hello") ["h" "e" "l" "l" "o"])
59-
(test:eq (list:map (string:codepoints "🏳️‍⚧️") string:ord) [127987 65039 8205 9895 65039]) })
58+
(test:eq (string:codepoints "hello") [104 101 108 108 111])
59+
(test:eq (string:codepoints "🏳️‍⚧️") [127987 65039 8205 9895 65039]) })
6060

6161
(test:case "ord, chr" {
6262
(test:eq (builtin__string:ord "a") (string:ord "a"))

0 commit comments

Comments
 (0)