24
submitted 19 hours ago by Val@lemm.ee to c/programming@programming.dev

After needing to find a small delimiter for my data format I started wondering if I could use 0x1E-0x1F?

They are part of the control codes so I thought they might do something weird?

https://en.wikipedia.org/wiki/C0_and_C1_control_codes#Field_separators

top 11 comments
sorted by: hot top controversial new old
[-] FizzyOrange@programming.dev 19 points 16 hours ago

Generally a bad idea to use in-band signalling like that. They won't do anything weird but consider what happens if the actual data contains them.

[-] dgriffith@aussie.zone 5 points 13 hours ago* (last edited 13 hours ago)

consider what happens if the actual data contains them.

Then you'd escape them by using another character in front. But if their data format is ASCII text or is guaranteed not to have characters below ASCII 32 then using ASCII delimiters is fine.

[-] lurklurk@lemmy.world 2 points 1 hour ago* (last edited 1 hour ago)

Then you can just use a conmon delimiter like comma or semicolon or something. It's better even as you're less likely to have something that seems to work until your exotic delimiter pops up in the data.

Better yet, use a commonly used data format like csv or json and don't build your own

[-] FizzyOrange@programming.dev 2 points 2 hours ago

Indeed. Escape characters add a lot of additional complexity, footguns, and performance penalties.

[-] SpaceNoodle@lemmy.world 7 points 12 hours ago

But who escapes the escape characters?

[-] Val@lemm.ee 1 points 4 hours ago
[-] SpaceNoodle@lemmy.world 3 points 4 hours ago

Use emoji as escape characters

[-] QuazarOmega@lemy.lol 7 points 12 hours ago

It's escape characters all the way down

[-] SpaceNoodle@lemmy.world 22 points 17 hours ago

1E and 1F were actually originally intended to be used as record and unit separators, respectively, so that's actually not a bad idea. The description for those fields in the article you linked even mentions that they're suited for use as field delimiters.

[-] bamboo@lemm.ee 8 points 18 hours ago

Depends on if you want your data format to be strict ascii. If you don’t care, then sure, why not?

[-] MinekPo1@lemmygrad.ml 1 points 14 hours ago* (last edited 14 hours ago)

depends on your format ? if the format is binary anyway or has binary blobs (ie it needs a program that is able to handle octets outside the printable range) and using those characters does not introduce any ambiguities with the format then go for it . ANSI and related control codes all start with 0x1B

this post was submitted on 27 Dec 2024
24 points (100.0% liked)

Programming

17680 readers
138 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS