- `iter.flatten`
- `-Dvariable=value` command line option to add symbols to the `runtime.vars` package.
- `--no-type-info` command line option to omit type information from the binary.
-- `conv.encode_hex` and `conv.decode_hex`
- - Quickly convrt a byte array to and from its hex equivalent.
+- `core.encoding.hex`
+ - Quickly convert a byte array to and from its hex equivalent.
Removals:
- Remove old syntax for quoted blocks, `#quote` and `#()`.
format_int :: i64_to_str
format_uint :: u64_to_str
-format_float :: f64_to_str
-
-
-
-
-encode_hex :: (s: str, allocator := context.allocator) -> str {
- #persist encode_map := u8.['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
-
- new_str := make([] u8, s.count * 2, allocator);
- for i: s.count {
- new_str[2 * i + 0] = encode_map[(s[i] & 0xf0) >> 4];
- new_str[2 * i + 1] = encode_map[s[i] & 0xf];
- }
-
- return new_str;
-}
-
-decode_hex :: (s: str, allocator := context.allocator) -> str {
- assert(s.count & 1 == 0, "Expected string of even length");
-
- new_str := make([] u8, s.count >> 1, allocator);
- for i: range.{0, s.count, 2} {
- new_str[i >> 1] = ~~((digit_to_value(s[i + 0]) << 4) | (digit_to_value(s[i + 1])));
- }
-
- return new_str;
-
- digit_to_value :: (it: u8) -> u32 {
- switch it {
- case #char "0" .. #char "9" do return ~~(it - #char "0");
- case #char "a" .. #char "f" do return ~~(it - #char "a" + 10);
- case #char "A" .. #char "F" do return ~~(it - #char "A" + 10);
- }
-
- return 0;
- }
-}
\ No newline at end of file
+format_float :: f64_to_str
\ No newline at end of file
--- /dev/null
+package core.encoding.hex
+
+encode :: (s: str, allocator := context.allocator) -> str {
+ #persist encode_map := u8.['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
+
+ new_str := make([] u8, s.count * 2, allocator);
+ for i: s.count {
+ new_str[2 * i + 0] = encode_map[(s[i] & 0xf0) >> 4];
+ new_str[2 * i + 1] = encode_map[s[i] & 0xf];
+ }
+
+ return new_str;
+}
+
+decode :: (s: str, allocator := context.allocator) -> str {
+ assert(s.count & 1 == 0, "Expected string of even length");
+
+ new_str := make([] u8, s.count >> 1, allocator);
+ for i: range.{0, s.count, 2} {
+ new_str[i >> 1] = ~~((digit_to_value(s[i + 0]) << 4) | (digit_to_value(s[i + 1])));
+ }
+
+ return new_str;
+
+ digit_to_value :: (it: u8) -> u32 {
+ switch it {
+ case #char "0" .. #char "9" do return ~~(it - #char "0");
+ case #char "a" .. #char "f" do return ~~(it - #char "a" + 10);
+ case #char "A" .. #char "F" do return ~~(it - #char "A" + 10);
+ }
+
+ return 0;
+ }
+}
\ No newline at end of file
#load "./time/date"
#load "./encoding/base64"
+#load "./encoding/hex"
#load "./encoding/utf8"
#load "./encoding/osad"
#load_all "./encoding/json"
s := "The quick brown fox jumps over the lazy dog";
println(s);
- encoded := conv.encode_hex(s);
+ encoded := encoding.hex.encode(s);
println(encoded);
- decoded := conv.decode_hex(encoded);
+ decoded := encoding.hex.decode(encoded);
println(decoded);
}