concordancejs / concordance

Compare, format, diff and serialize any JavaScript value
ISC License
207 stars 15 forks source link

Escape or replace invisible or ambiguous characters when formatting strings #4

Open novemberborn opened 7 years ago

novemberborn commented 7 years ago

Invisible characters such as zero-width joiner and non-breaking space, as well as ambiguous characters like other kinds of spaces, combining characters et cetera should be escaped when strings are formatted.

http://graphemica.com/blocks/control-pictures should be used where the behavior of the original character is preserved. This probably only applies to linebreaks.

If a simple escape sequence exist it should be used. Else characters should be escaped using the \u sequence.

When a string is formatted as a key it must not include linebreaks.

sindresorhus commented 7 years ago

If a simple escape sequence exist it should be used.

What is a "simple escape sequence"?

novemberborn commented 7 years ago

What is a "simple escape sequence"?

\t would be a simple sequence, as opposed to \u0009.

novemberborn commented 6 years ago

ANSI codes should also be escaped.

IssueHuntBot commented 5 years ago

@issuehunt has funded $40.00 to this issue.


novemberborn commented 4 years ago

It'd be great if we could show byte differences when characters look the same, like in this example: https://github.com/avajs/ava/issues/2451