File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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)))
Original file line number Diff line number Diff line change 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"))
You can’t perform that action at this time.
0 commit comments