File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -379,14 +379,17 @@ func FuzzCobs(f *testing.F) {
379379}
380380
381381func ExampleEncode () {
382- data := "Hello"
383- encoded := Encode (Terminate ([]byte (data )))
384- fmt .Printf ("%v: %v\n " , data , encoded )
385- decoded := TrimNull (Decode (encoded ))
386- fmt .Printf ("%v: %v\n " , encoded , string (decoded ))
382+ data := []byte ("Hello\x00 World\x00 " )
383+
384+ enc := Encode (data )
385+ fmt .Printf ("Encode: % x → % x\n " , data , enc )
386+
387+ dec := Decode (enc )
388+ fmt .Printf ("Decode: % x → % x\n " , enc , dec )
389+
387390 // Output:
388- // Hello: [6 72 101 108 108 111]
389- // [6 72 101 108 108 111]: Hello
391+ // Encode: 48 65 6c 6c 6f 00 57 6f 72 6c 64 00 → 06 48 65 6c 6c 6f 06 57 6f 72 6c 64
392+ // Decode: 06 48 65 6c 6c 6f 06 57 6f 72 6c 64 → 48 65 6c 6c 6f 00 57 6f 72 6c 64 00
390393}
391394
392395func benchmarkEncode (i int , b * testing.B ) {
You can’t perform that action at this time.
0 commit comments