[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncurses & utf-8
From: |
folkert |
Subject: |
Re: ncurses & utf-8 |
Date: |
Fri, 16 Aug 2013 11:57:58 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Never mind, the bug was somewhere else.
On Fri, Aug 16, 2013 at 10:10:10AM +0200, folkert wrote:
> Hi,
>
> I'm trying to output UTF-8 codes that I retrieve from a stream.
> So first I collect the bytes that make-up the utf-8 code and put them in
> a buffer. Then I output them using waddstr().
> Before I start ncurses I do:
> /setlocale(LC_ALL,"C-UTF-8");
> also tried:
> setlocale(LC_CTYPE, "");
> Am linking against libncursesw.
>
> Any suggestions?
>
> char utfbuffer[5];
> unsigned char first = (unsigned char)string[loop];
>
> if ((first & 0xe0) == 0xc0)
> {
> utfbuffer[0] = string[loop];
> utfbuffer[1] = string[loop + 1];
> utfbuffer[2] = 0x00;
> loop += 1;
> }
> else if ((first & 0xf0) == 0xe0)
> {
> utfbuffer[0] = string[loop];
> utfbuffer[1] = string[loop + 1];
> utfbuffer[2] = string[loop + 2];
> utfbuffer[3] = 0x00;
> loop += 2;
> }
> else if ((first & 0xf8) == 0xf0)
> {
> utfbuffer[0] = string[loop];
> utfbuffer[1] = string[loop + 1];
> utfbuffer[2] = string[loop + 2];
> utfbuffer[3] = string[loop + 3];
> utfbuffer[4] = 0x00;
> loop += 3;
> }
> else
> {
> utfbuffer[0] = string[loop];
> utfbuffer[1] = 0x00;
> }
>
> waddstr(win, utfbuffer);
>
>
> Folkert van Heusden
>
> --
> MultiTail er et flexible tool for å kontrolere Logfiles og commandoer.
> Med filtrer, farger, sammenføringer, forskeliger ansikter etc.
> http://www.vanheusden.com/multitail/
> ----------------------------------------------------------------------
> Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
Folkert van Heusden
--
Multi tail barnamaj mowahib li mora9abat attasjilat wa nataij awamir
al 7asoub. damj, talwin, mora9abat attarchi7 wa ila akhirih.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com