[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cast char to chtype ?

From: Mike Gran
Subject: Re: cast char to chtype ?
Date: Tue, 4 Aug 2015 23:10:51 +0000 (UTC)

> On Tuesday, August 4, 2015 3:50 PM, Patrick <address@hidden> wrote:

> > Hi Everyone
> I haven't tried to do this yet because I was unsure if it was safe even 
> if it appeared to work. Is it safe to cast a char to a chtype ? I have a 
> situation were the input is from a piece of code that has not yet 
> resolved ncurses and needs to use the basic C types.

It is safe for 7-bit characters.

For 8-bit locales, like Latin1, you have to make sure to get the
signs right, like with the double cast below.  The resulting chtype
will not have any attributes or color pair.

char c = 'x';

chtype c2 = (chtype) (unsigned char) c;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]