[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: utf-8 & ncurses
From: |
folkert |
Subject: |
Re: utf-8 & ncurses |
Date: |
Tue, 17 Aug 2010 11:16:27 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>> I'm trying to get ncurses and utf-8 to work with each other.
>> Let's say I have a string 'string' and an index 'loop'. Now in this
>> string some utf-8 characters may exist. I try to filter these out and
>> print them.
>>
>> #include <ncursesw/ncurses.h>
>>
>> if ((string[loop] & 0xe0) == 0xc0)
>> {
>> wadd_wch(win -> win, (string[loop] << 8) + string[loop + 1]);
>> loop += 1;
>> }
>> else if ((string[loop] & 0xf0) == 0xe0)
>> {
>> wadd_wch(win -> win, (string[loop] << 16) + (string[loop + 1]
>> << 8) + string[loop + 2]);
>> loop += 2;
>> }
>> ....
>>
>> This doesn't work. No special characters are shown.
>
> The conversion doesn't look right. Basically, UTF-8 uses a few bits from
> each byte to tell where it is in a multibyte sequence, and a few bits from
> each byte are masked into the result.
So what you mean is that I need to strip of those markerbits,
concatenate the remaining bits into some variable and then use waddch to
print it?
Folkert van Heusden
--
MultiTail รจ uno flexible tool per seguire di logfiles e effettuazione
di commissioni. Feltrare, provedere da colore, merge, 'diff-view',
etc. http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com