LemonBoy / bar

A featherweight, lemon-scented, bar based on xcb
MIT License
1.63k stars 194 forks source link

Add support for unicode-7 characters #99

Closed ZyX-I closed 9 years ago

ZyX-I commented 9 years ago

I have not actually tried bar, but I see in your code that it uses uint16_t for representing a character. This obviously means that unicode code points above U+FFFF cannot be represented. If I am not mistaking they will fall into an else clause which is talking about some nonsense (“Handle ascii > 0x80”: there is no such a thing because ASCII only defines characters up to 0x7F, characters above are part of latin1 encoding if you want to have character value == unicode codepoint).

LemonBoy commented 9 years ago

The limitation is imposed by Xorg itself, it can't use more than 16 bits for codepoint, so this issue is a no-go (at least until I move away from server side rendering) But you're right, that comment is incorrect, will adjust that soon :)

ZyX-I commented 9 years ago

@LemonBoy I would suggest to show U+FFFD REPLACEMENT CHARACTER in place of Unicode-7 characters then, not treat this as latin1.

LemonBoy commented 9 years ago

This should do the trick, sadly many fonts don't even have the U+FFFD character, but that's another problem

ZyX-I commented 9 years ago

I guess they are relying on fallbacks. I.e. there is no character in font, but either

  1. fontconfig or something similar is able to take the character from some other font which has it.
  2. terminal or whatever is going to display this thing has its own variant of REPLACEMENT CHARACTER (e.g. like GTK that displays big box with hexadecimal digits).

Cannot say how XCB copes with this problem.

LemonBoy commented 9 years ago

You should take into account that XCB doesn't even support unicode, but ucs-2