hardfork
hardfork

Reputation: 3261

Why does Unicode have 2 spaces? What's the difference?

I just saw that Unicode has 2 space characters within its first 200 entries: 0x20 and 0xa0

I know the entity of 0xa0 from HTML (it's   there) and I know that 0x20 is also a space-character in the ASCII table.

So what's the difference between them and why do we need 2 of them?

Upvotes: 3

Views: 4946

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20812

It's about line breaks, or in particular, word wrapping.

U+0020 SPACE is for when you want a word separator in a place where a line break is acceptable.

U+00A0 NBSP is for when you want a word separator in a place where a line break is undesirable.

See Table 1 in UNICODE LINE BREAKING ALGORITHM.

GL    Non-breaking (“Glue”)   CGJ, NBSP, ZWNBSP   Prohibit line breaks before and after
SP    Space                   SPACE               Enable indirect line breaks

Upvotes: 7

Related Questions