Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

curses (or ncurses) output of UTF-8 test with addchstr()
In curses (or ncurses), how can I output a UTF-8 encoded char* by using
addchstr() (or any other function taking a 'chtype' as argument)?

This (obviously) won't work:

(It's C99.)


const char* utf8Str = "Some UTF-8 text here";
chtype cursesStr[SOME_SIZE];

for (size_t i = 0; i < strlen(utf8Str); ++i) {
cursesStr[i] = utf8Str[i] | A_CURSES_ATTRIBUTE_WE_WANT;
}
cursesStr[i] = 0;

addchstr(cursesStr);


I guess I would have to combine every UTF-8 multibyte sequence in
utf8Str into a single chtype and store that in cursesStr.  I can't seem
to succeed in it.  Is it even possible to use addchstr() and friends for
UTF-8 strings?  Or would I have to convert from UTF-8 to some other
Unicode encoding?  If yes, which one?  If no, what are my options?

Report this thread to moderator Post Follow-up to this message
Old Post
Nikos Chantziaras
03-30-08 01:17 PM


Re: curses (or ncurses) output of UTF-8 test with addchstr()
Nikos Chantziaras <realnc@arcor.de> wrote:
> In curses (or ncurses), how can I output a UTF-8 encoded char* by using
> addchstr() (or any other function taking a 'chtype' as argument)?

In ncurses, you can (assuming your locale is already using a UTF-8 encoding)
use addstr.  More generally (or to pass along an attribute), you would use
setcchar, as illustrated in ncurse's test/view.c

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

Report this thread to moderator Post Follow-up to this message
Old Post
Thomas Dickey
03-31-08 02:09 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:15 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.