all repos

gbf @ dc12bd2

⭐ gleaming brainfuck
1 files changed, 9 insertions(+), 8 deletions(-)
support all ansii chars
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-10-17 16:29:09 +0300
Change ID: vpnkknrpzllvrtmvomxsnoyyyxvyqqmp
Parent: 5bba89b
M src/char.gleam

@@ -1,20 +1,21 @@

+import gleam/bit_array import gleam/string pub fn to_code(s: String) { - case <<s:utf8>> { - // lowercase a(ansii 97) to z(ansii 122) - <<char:int>> if char >= 97 -> char - 96 - - // uppercase A(ansii 65) to Z(ansii 90), and special symbols - <<char:int>> -> char - 38 - + let bytes = bit_array.from_string(s) + case bit_array.byte_size(bytes) { + 1 -> + case bytes { + <<value>> -> value + _ -> 0 + } _ -> 0 } } pub fn from_code(code: Int) { case code { - c if c == 0x0A || c >= 0x20 && c <= 0x7E -> { + c if c >= 1 && c <= 255 -> { case string.utf_codepoint(code) { Ok(codepoint) -> string.from_utf_codepoints([codepoint]) Error(_) -> ""