Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zero-width/invisible characters to force custom ordering

Tags:

utf-8

What zero-width characters exist in UTF-8 that are not treated as spaces1? I am particularly interested in those which glyphs that do not render on major browsers: the not-found rectangle should never be shown.

There are many web services that order user entered data alphabetically (eg. Gmail's labels). I would like to use those invisible characters to enforce custom ordering.

1 Treated as spaces: not removed by commonly used implementations of trim and similar. With the gmail example, U+202F (Narrow no-break space) is trimmed.

Edit: Only one invisible character should suffice. After all, they may be repeated without having an effect on the visual representation (assuming a lower code ascii text follows):

[char]Z on first position
[char][char]B on second position
[char][char][char]C on third position

Unfortunately, all characters I could think of are either trimmed right away or ignored by sort functions.

Edit: I've browsed through all UTF-8 characters that seemed zero width / invisible and none worked as required. U+0 - U+20, DEL, Control chars, even symbols such as U+034F: COMBINING GRAPHEME JOINER (alias CGJ), all are treated properly and thus unusable for my purpose. I keep searching though.

like image 989
Mikulas Dite Avatar asked Sep 24 '12 17:09

Mikulas Dite


1 Answers

You could try the following ones:

U+200B ZERO WIDTH SPACE 
U+200C ZERO WIDTH NON-JOINER  
U+200D ZERO WIDTH JOINER
like image 163
Nelson Avatar answered Sep 28 '22 11:09

Nelson