use encoding::hex; use fmt; use os; use strings; use unicode; export fn main() void = { const input = os::args[1]; const data = strings::toutf8(input); hex::dump(os::stdout, data)!; fmt::println(input)!; let ix = 0u; const lb = unicode::new_line_breaker(input); for (const (pos, _, mand) => unicode::next_line_break(&lb)) { for (ix < pos; ix += 1) { fmt::print(' ')!; }; ix += 1; if (mand) { fmt::println('|')!; } else { fmt::print('^')!; }; }; fmt::println()!; fmt::println()!; fmt::println("Line break opportunities:")!; const lb = unicode::new_line_breaker(input); for (const (pos, bpos, mand) => unicode::next_line_break(&lb)) { fmt::printfln("- {}:{} {} (before '{}'/0x{:x})", pos, bpos, if (mand) "(mandatory)" else "", strings::sub(input, pos, pos+1), data[bpos])!; }; };