riggsd / guano-py

Python reference implementation of the GUANO bat acoustics metadata specification
http://guano-md.org
MIT License
13 stars 5 forks source link

Multi-Line String Escaping #6

Closed riggsd closed 7 years ago

riggsd commented 7 years ago

Because the '\n' character is used as a field delimiter, the spec defines the two-character string "\n" as an embedded newline within a field value. Without further escaping rules, this makes it impossible to intentionally use those characters together.

For example, a field may have a Windows filesystem path as value, C:\bat_calls\new\, but a newline would inadvertently be inserted between C:\bat_calls and new\.

  1. Should we then define the two-character string "\\" to represent the character '\'? The above example would then need to be encoded as C:\\bat_calls\\new\\.

  2. It should also be decided if these special escape characters apply to all string values, or exclusively to fields which specify "multi-line string" values?

For what it's worth, escaping a single token like "\n" is simple; simultaneously escaping several tokens, especially tokens containing the '\' character (which itself escapes special characters in C-based languages), is non-trivial.