mirror of
https://github.com/carp-lang/Carp.git
synced 2024-07-14 16:40:26 +03:00
feat: add Char.to-byte and Char.from-byte (#1187)
This commit is contained in:
parent
007d020e05
commit
459a62e61f
@ -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.<)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user