diff --git a/format/text/encoding.go b/format/text/encoding.go index ffaa0070..05f82d21 100644 --- a/format/text/encoding.go +++ b/format/text/encoding.go @@ -31,7 +31,7 @@ func init() { } return bb }) - interp.RegisterFunc0("to_hex", func(_ *interp.Interp, c string) any { + interp.RegisterFunc0("to_hex", func(_ *interp.Interp, c any) any { br, err := interp.ToBitReader(c) if err != nil { return err @@ -73,7 +73,7 @@ func init() { type toBase64Opts struct { Encoding string } - interp.RegisterFunc1("_to_base64", func(_ *interp.Interp, c string, opts toBase64Opts) any { + interp.RegisterFunc1("_to_base64", func(_ *interp.Interp, c any, opts toBase64Opts) any { br, err := interp.ToBitReader(c) if err != nil { return err diff --git a/format/text/testdata/random.bin.gz b/format/text/testdata/random.bin.gz new file mode 100644 index 00000000..3aa3a1ef Binary files /dev/null and b/format/text/testdata/random.bin.gz differ diff --git a/format/text/testdata/to_base64.fqtest b/format/text/testdata/to_base64.fqtest new file mode 100644 index 00000000..c8d2b3d5 --- /dev/null +++ b/format/text/testdata/to_base64.fqtest @@ -0,0 +1,2 @@ +$ fq '.uncompressed | to_base64' random.bin.gz -r +8Vr6cUH6erA= diff --git a/format/text/testdata/to_hex.fqtest b/format/text/testdata/to_hex.fqtest new file mode 100644 index 00000000..356a1f80 --- /dev/null +++ b/format/text/testdata/to_hex.fqtest @@ -0,0 +1,2 @@ +$ fq '.uncompressed | tohex' random.bin.gz -r +f15afa7141fa7ab0