diff --git a/core/Char.carp b/core/Char.carp index bc514cc0..568679de 100644 --- a/core/Char.carp +++ b/core/Char.carp @@ -6,6 +6,8 @@ (register > (Fn [Char Char] Bool)) (register to-int (Fn [Char] Int)) (register from-int (Fn [Int] Char)) + (register to-byte (Fn [Char] Byte)) + (register from-byte (Fn [Byte] Char)) (register copy (Fn [&Char] Char)) (implements < Char.<) diff --git a/core/carp_char.h b/core/carp_char.h index 66afbd0f..7b7ab774 100644 --- a/core/carp_char.h +++ b/core/carp_char.h @@ -18,6 +18,14 @@ Char Char_from_MINUS_int(int i) { return (Char)i; } +int Char_to_MINUS_byte(Char c) { + return (uint8_t)c; +} + +Char Char_from_MINUS_byte(uint8_t i) { + return (Char)i; +} + Char Char_copy(const Char *c) { return *c; } diff --git a/test/char.carp b/test/char.carp index 9cee86b1..c944649f 100644 --- a/test/char.carp +++ b/test/char.carp @@ -134,4 +134,12 @@ (assert-true test (alphanum? \0) "alphanum? works as expected III") + (assert-equal test + 48b + (to-byte \0) + "to-byte works as expected") + (assert-equal test + \A + (from-byte 65b) + "from-byte works as expected") )