char2uni(3x)

πŸ¦‹ char2uni(3x) πŸ¦‹ β€” the AfterStep X11 window manager girlies know

okay so bestie, real talk: this page is char2uni(3x) from the AfterStep X11 window manager docs, and it's all about Unicode, UTF-8, and localized 8-bit encodings. it's short, it's iconic, it ate. let's get into it πŸ’…


✨ NAME ✨

  • char2uni β€” handling on Unicode, UTF-8 and localized 8 bit encodings
  • libAfterImage/CHAR_SIZE

πŸŽ€ NAMECHAR_SIZE πŸŽ€

so CHAR_SIZE is a convenient macro and its whole vibe is: we need to transparently determine the number of bytes that character spans. that's it, that's the job. 🫢

and here's the tea β€” it assumes UTF-8 encoding when I18N is enabled. no cap. 🌈


πŸ”₯ SOURCE πŸ”₯

this is the source, verbatim, every last character, do not touch, she is perfect:

/* size of the UTF-8 encoded character is based on value of
 * the first byte : */ #define UTF8_CHAR_SIZE(c)
((((c)&0xC0)==0xC0)? \
                             (((c)&0x20)? \
                             (((c)&0x10)? \
                             (((c)&0x08)? \
                             (((c)&0x04)?6:5):4):3):2):1) #ifdef
WIN32 #define UNICODE_CHAR_SIZE(c)    sizeof(UNICODE_CHAR) #endif
#define CHAR_SIZE(c)            1

like… the way that UTF8_CHAR_SIZE peeks at the value of the first byte to figure out the size of the UTF-8 encoded character? obsessed. 😭✨ and UNICODE_CHAR_SIZE straight up hands you sizeof(UNICODE_CHAR), while CHAR_SIZE is just chillin' at 1. slay. πŸ‘‘


πŸ’– that's literally the whole page, bestie. nothing more, nothing less, and we love a concise queen.

sign-off 🧚 β€” this lil masterpiece comes to you courtesy of the 3rd Berkeley Distribution and AfterStep v.2.2.12. char2uni(3x), periodt. πŸŒΈπŸ¦‹β­

πŸ“¦ where this page comes from