diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-09 21:56:54 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-09 21:56:54 +0200 |
| commit | 912f99abc8942dd4d1111ccd8f892e8c8e52b29b (patch) | |
| tree | c885b4853f1e003a06c50ce05ca55d5737e47c2a /core/encoding/hex | |
| parent | c5ed7083d2fa4c47adb61dd529475194515cc74f (diff) | |
encoding/cbor: various fixes
- "null" is the proper way to represent the nil value in the diagnostic
format
- hex encoding in diagnostic format was wrong
- struct keys weren't sorted the right deterministic way
Diffstat (limited to 'core/encoding/hex')
| -rw-r--r-- | core/encoding/hex/hex.odin | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/encoding/hex/hex.odin b/core/encoding/hex/hex.odin index c2cd89c5b..c1753003e 100644 --- a/core/encoding/hex/hex.odin +++ b/core/encoding/hex/hex.odin @@ -1,5 +1,6 @@ package encoding_hex +import "core:io" import "core:strings" encode :: proc(src: []byte, allocator := context.allocator, loc := #caller_location) -> []byte #no_bounds_check { @@ -14,6 +15,12 @@ encode :: proc(src: []byte, allocator := context.allocator, loc := #caller_locat return dst } +encode_into_writer :: proc(dst: io.Writer, src: []byte) -> io.Error { + for v in src { + io.write(dst, {HEXTABLE[v>>4], HEXTABLE[v&0x0f]}) or_return + } + return nil +} decode :: proc(src: []byte, allocator := context.allocator, loc := #caller_location) -> (dst: []byte, ok: bool) #no_bounds_check { if len(src) % 2 == 1 { |