Leave these fields empty (spam trap):
Name
You can leave this blank to post anonymously, or you can create a Tripcode by using the format Name#Password
Comment
[i]Italic Text[/i]
[b]Bold Text[/b]
[spoiler]Spoiler Text[/spoiler]
>Highlight/Quote Text
[pre]Preformatted & Monospace Text[/pre]
[super]Superset Text[/super]
[sub]Subset Text[/sub]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists
File

Sandwich


Discord Now Fully Linked With 420chan IRC

Python Curses and Unicode?

Reply
- Thu, 15 Jun 2017 00:06:52 EST UelYniJo No.37066
File: 1497499612658.jpg -(141192B / 137.88KB, 1920x1200) Thumbnail displayed, click image for full size. Python Curses and Unicode?
Hai /prog/ How do you print Unicode characters with the curses engine? I've tried googling it, but can't find a direct answer. I get a UnicodeEncodeError when using the addstr(). Does curses not support Unicode? Are there other options to use that are like curses but use Unicode? I don't wanna go to stackexchange cuz they're dicks
>>
Cornelius Cungerstock - Thu, 15 Jun 2017 00:08:28 EST UelYniJo No.37067 Reply
and to clarify I'm using Python
>>
Nicholas Dartman - Fri, 16 Jun 2017 08:38:24 EST bfXfOa6l No.37069 Reply
Can you post some code?
>>
Emma Hogglesutch - Fri, 16 Jun 2017 20:00:57 EST t8PnzZ4L No.37070 Reply
>>37068
yea this was it. but now my problem is trying to define my own colors in curses. Does python curses only support 256 colors? when I run can_change_color() I get true,. I've heard mention of init_color() function but it doesn't seem to work for me.

So am I limited to the 256 default colors in python curses? I didn't wanna make a new thread.
>>
Nell Blipperway - Sat, 17 Jun 2017 09:06:10 EST oV3ReYbN No.37071 Reply
I tried doing this, but no change is observed even after I change the parameters:

curses.start_color()#enable color
#curses.use_default_colors()

curses.init_color(17, 200,200,200)

curses.init_pair(1, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(4, 17, curses.COLOR_BLACK)

I try loading different rgb values in init_color, but no matter what three RGB values I put in, color number 17 stays the same when I call it with pair 4.

Does anyone know what I might be doing wrong? I'm using Mac btw
>>
Beatrice Segglekedge - Sat, 17 Jun 2017 11:13:43 EST WLOo3E7i No.37072 Reply
>>37071
You can check how many colors curses supports with curses.COLORS

Also, after you set 17 to your color, try curses.color_content(17), to see if it was actually changed
>>
Phyllis Bummerhadge - Sat, 17 Jun 2017 22:33:22 EST oV3ReYbN No.37076 Reply
>>37072
the damndest thing:

curses.color_content(17) returns (200, 200, 200) even though the text shown is dark blue. Is there some kind of flush/update funciton you need to call to update the colors??
>>
Fuck Blatherwill - Sun, 18 Jun 2017 17:56:13 EST WXeXtUgF No.37077 Reply
>>37076
Why don't you just ask someone to make whatever this is for you? If you're trying to learn, you're doing a very poor job of it.
>>
Albert Sizzledale - Sun, 18 Jun 2017 19:37:23 EST DCp+Agav No.37078 Reply
>>37077
ayy fuck you dawg, just asking a question about a jenky api.

if you don't wanna help, move along faggot
>>
Nicholas Lightville - Thu, 22 Jun 2017 15:27:38 EST iY001LBY No.37081 Reply
>>37080

curses.start_color()
curses.init_color(17, 200,200,200)

curses.init_pair(1, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(4, 17, curses.COLOR_BLACK)

print curses.can_change_color() #returns True
print curses.color_content(17) #(200,200,200),
stdscr.addstr("test",curses.color_pair(4)) #yet this text is blue
>>
Rebecca Bremblefetch - Thu, 22 Jun 2017 17:23:15 EST eHw3w0GL No.37082 Reply
1498166595626.gif -(1025807B / 1001.76KB, 240x190) Thumbnail displayed, click image for full size.
>>37081
I got the same result using xterm. To fix it I had to add this line to ~/.Xresources:

xterm*color255: true

And set the terminal:

export TERM=xterm-256color

I think if you just set TERM then it pretends to work, but actually doesn't.

Hope that helps.
>>
Angus Fonderdock - Sat, 24 Jun 2017 23:57:48 EST h+zCLZ09 No.37083 Reply
>>37082
>>37082
Thanks for the suggestion pal. It didn't quite work for me, but I might be doing it wrong. Are you using the default Mac terminal or do you use the Xquartz terminal? I'm using the default generic one. I installed Xquartz - does the Xresources file apply to only the xquartz terminal, or does it also apply to the default Mac terminal?
Thanks for the assistance!
>>

Report Post
Reason
Note
Please be descriptive with report notes,
this helps staff resolve issues quicker.