From 912f99abc8942dd4d1111ccd8f892e8c8e52b29b Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 9 Aug 2024 21:56:54 +0200 Subject: 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 --- core/encoding/hex/hex.odin | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/encoding/hex') 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 { -- cgit v1.2.3