+ if self >= b'A' then return true
+ if self <= b'9' and self >= b'0' then return true
+ return false
+ end
+
+ # Returns the `base64` equivalent of `self`
+ #
+ # REQUIRE `self`.`is_base64_char`
+ fun to_base64_char: Byte do
+ if self == b'+' then return 62u8
+ if self == b'/' then return 63u8
+ if self > b'Z' then
+ if self < b'a' then abort
+ if self <= b'z' then return self - 71u8
+ abort
+ end
+ if self >= b'A' then return self - 0x41u8
+ if self <= b'9' and self >= b'0' then return self + 4u8
+ abort
+ end
+end
+
+redef class CString
+ # Alphabet used by the base64 algorithm
+ private fun base64_chars : Bytes
+ do
+ return b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"