torrust / bencode2json

A Bencoded to JSON converter library and console app with no intermediary in-memory structure.
https://crates.io/crates/bencode2json
GNU Lesser General Public License v3.0
1 stars 2 forks source link

How do you represent bencoded strings that contain a `<hex>` tag to avoid ambiguity? #7

Open josecelano opened 4 hours ago

josecelano commented 4 hours ago

Relates to: https://github.com/Chocobo1/bencode_online/issues/3

How do you represent bencoded strings that contain a tag to avoid ambiguity with the tags introduced by not utf-8 bencoded strings?

Submitted on reddit by Icarium-Lifestealer

josecelano commented 3 hours ago

Maybe we can always include some tags. For byte sequences containing valid UTF-8:

"<utf8>spam</utf8>"

And not UTF-8 sequences:

"<bytes>fffe</bytes>"

The encoded value 6:<utf8> would be "<utf8><utf8></utf8>".

Maybe we can event simplify the metadata using just a prefix instead of a html-style tag:

"utf8:spam"

And not UTF-8 sequences:

"bytes:fffe"

What do you think @da2ce7 @mario-nt ? It's just the first idea I came up with.