Feb 12

When posting the python below, I used the non-breaking space HTML entity to make sure the indentation of the code was correct. But what if you want monospaced text with word wrap? You can simply use regular spaces, but multiple regular spaces in a row are contracted to a single space. So the following:

1 2 3 4 5 6 7 8 ← count
  x x   x  x  x  ← clave

comes out as:

1.2.3.4.5.6.7.8. ← count
x x x x x ← clave

Not a whole lot of use. What I want is a non-breaking space that breaks. Or better, a space that doesn’t collapse. Let’s see what HTML entities we have to play with.

  em space
  en space
  no-break space = non-breaking space
  thin space
‍ zero width joiner
‌ zero width non-joiner

well,   and   are, as their names suggest, a space-as-wide-as-an-n and a space-as-wide-as-an-m. What does this mean in a fixed-width font? One might be forgiven for thinking they are the same as one another.

But they’re not. In the fixed-width Courier font, we get this:

[nnnnnnnnnn] ← 10 ens
[          ] ← 10 en spaces
[mmmmmmmmmm] ← 10 ems
[          ] ← 10 em spaces.

(Oo, I notice that works fine in Internet Explorer! Firefox got it wrong though!)

Well, thought I, in a moment of genius, how about a zero-width non-joiner then? If I have a non-breaking space followed by a character that can break, surely that’s like a fixed-width breaking space?

 ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ← I don’t know about you, but I see a whole load of crappy lines there.

Executive summary: the web is STILL broken.

Addendum: wordpress’s editor HATES this post!

 

February 2008
S M T W T F S
« Jan   Mar »
 12
3456789
10111213141516
17181920212223
242526272829  

Archives

Meta