usv 0.7.0

USV: Unicode Separated Values for data markup, including for spreadsheets, databases, text files, and more. Improves on CSV, TSV, ASV.
Documentation

Unicode Separated Values (USV)

Unicode separated values (USV) is a data format that uses Unicode symbol characters between data parts.

The USV repo is https://github.com/sixarm/usv.

USV characters

Separators:

  • ␟ U+241F Symbol for Unit Separator (US).

  • ␞ U+241E Symbol for Record Separator (RS).

  • ␝ U+241D Symbol for Group Separator (GS).

  • ␜ U+241C Symbol for File Separator (FS).

Modifiers:

  • ␛ U+241B Symbol for Escape (ESC).

  • ␗ U+2417 Symbol for End of Transmission Block (ETB).

Units

use usv::*;
let input = "a␟b␟";
let units: Vec<String> = input.units().collect();
assert_eq!(
    units,
    vec![
        String::from("a"),
        String::from("b"),
    ]
);

Records

use usv::*;
let input = "a␟b␟␞c␟d␟␞";
let records: Vec<String> = input.records().collect();
assert_eq!(
    records,
    vec![
        String::from("a␟b␟"),
        String::from("c␟d␟"),
    ]
);

Groups

use usv::*;
let input = "a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝";
let groups: Vec<String> = input.groups().collect();
assert_eq!(
    groups,
    vec![
        String::from("a␟b␟␞c␟d␟␞"),
        String::from("e␟f␟␞g␟h␟␞"),
    ]
);

Files

use usv::*;
let input = "a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝␜i␟j␟␞k␟l␟␞␝m␟n␟␞o␟p␟␞␝␜";
let files: Vec<String> = input.files().collect();
assert_eq!(
    files,
    vec![
        String::from("a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝"),
        String::from("i␟j␟␞k␟l␟␞␝m␟n␟␞o␟p␟␞␝"),
    ]
);

All together

use usv::*;
let input = "a␟b␟␞c␟d␟␞␝e␟f␟␞g␟h␟␞␝␜i␟j␟␞k␟l␟␞␝m␟n␟␞o␟p␟␞␝␜";
let mut string = String::new();
for file in input.files() {
    for group in file.groups() {
        for record in group.records() {
            for unit in record.units() {
                string += &unit;
            }
        }
    }
}
assert_eq!(
    string,
    String::from("abcdefghijklmnop"),
);