Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not render non-US-ASCII charcters #6

Closed
jeanlazarou opened this issue Jul 28, 2014 · 22 comments
Closed

does not render non-US-ASCII charcters #6

jeanlazarou opened this issue Jul 28, 2014 · 22 comments

Comments

@jeanlazarou
Copy link

If the code displays non-US-ASCII characters they do not appear as expected.

Add some accents to the sample/hello.rb example, like

  show_message("Hello, World!: éàù")

The message is displayed as:

                        ┌----------------------┐
                        |                      |
                        |  Hello, World!: M-CM-)
                        M-CM- M-CM-9           |
                        └----------------------┘
@smlx
Copy link

smlx commented Aug 3, 2014

Works for me (ruby 2.1.0, linux).

What's your platform?

@drbrain
Copy link
Member

drbrain commented Aug 3, 2014

On OSX curses appears to support only the basic multilingual plane so you can't print emoji, for example. It's also limited by your terminal's ability to perform glyph substitution.

I have used curses to display non-ASCII characters so a failing example and environment information will be needed.

@jeanlazarou
Copy link
Author

The platform I use is
Linux Mint 16 Cinnamon 64-bit version 2.0.14 (kernel 3.11.0-12),

the Ruby version is
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

I installed the gem using 'gem install curses', it installed
curses (1.0.1)

I edited the "hello.rb" example, added three accented characters, checked
the file was saved in UTF-8 and had the result mentioned in the issue, here
is the example code (I removed the shebang line and launched the script
with 'ruby hello.rb'):

require "curses"
include Curses

def show_message(message)
width = message.length + 6
win = Window.new(5, width,
(lines - 5) / 2, (cols - width) / 2)
win.box('|', '-')
win.setpos(2, 3)
win.addstr(message)
win.refresh
win.getch
win.close
end

init_screen
begin
crmode

show_message("Hit any key")

setpos((lines - 5) / 2, (cols - 10) / 2)
addstr("Hit any key")
refresh
getch
show_message("Hello, World! éàù")
refresh
ensure
close_screen
end

On Sun, Aug 3, 2014 at 9:37 PM, Eric Hodel notifications@github.com wrote:

On OSX curses appears to support only the basic multilingual plane so you
can't print emoji, for example. It's also limited by your terminal's
ability to perform glyph substitution.

I have used curses to display non-ASCII characters so a failing example
and environment information will be needed.


Reply to this email directly or view it on GitHub
#6 (comment).

@mcormier
Copy link
Contributor

@jeanlazarou

Try adding the line below to the top of your ruby file:
# -- encoding : utf-8 --

@jeanlazarou
Copy link
Author

@mcormier

It won't help (I used Ruby 2.1 which defaults to UTF-8).

@mcormier
Copy link
Contributor

I can render those characters in Ruby 1.9.3 and in 2.1.5, with Ruby curses on OS X. Maybe it's a limitation of the terminal you are using.

untitled

@mcormier
Copy link
Contributor

if

puts "Hello, World! éàù"

works in your terminal then you may need to take a look at your implementation of curses.

The gem simply binds to a unix .so file.

https://github.com/ruby/curses/blob/master/lib/curses.rb#L1

@jeanlazarou
Copy link
Author

The output from "puts" is fine, but curses is not...

I replaced the 'curses.so' file with other versions I had on my system and one of the fixed the problem. The version that fixes the problem comes from a Ruby 2.0.0 (not the one from the gem) and is also a x86_64-linux.

@mcormier
Copy link
Contributor

That's good news.
Are you using rvm to switch between ruby versions?
How did you replace the file? Did you edit lib/curses in the installed gem?
What was the full path of the object file?

@ghost
Copy link

ghost commented Jan 3, 2015

Same problem with Ruby 2.1.5 and Debian 8. I tried installing Ruby 2.0.0 with RVM and it fixed it. If possible I would like to find a better solution as I'm not a Ruby dev and I don't need two installs of Ruby nor RVM.

@jeanlazarou
Copy link
Author

@mcormier

Yes, I am using rvm.

I copied the file installed on my system at
/usr/lib/x86_64-linux-gnu/ruby/2.0.0/curses.so (52032 Sep 17 2013)

To my rvm gemset (named curses)

.rvm/gems/ruby-2.1.1@curses/extensions/x86_64-linux/2.1.0/curses-1.0.1/

@etm
Copy link

etm commented Mar 19, 2015

Same problem with Ruby 2.2.0 and Debian 8. I installed libncursesw5-dev, which adds

/.
/usr
/usr/share
/usr/share/doc
/usr/include
/usr/include/ncursesw
/usr/include/ncursesw/unctrl.h
/usr/include/ncursesw/term_entry.h
/usr/include/ncursesw/menu.h
/usr/include/ncursesw/termcap.h
/usr/include/ncursesw/etip.h
/usr/include/ncursesw/eti.h
/usr/include/ncursesw/cursesf.h
/usr/include/ncursesw/nc_tparm.h
/usr/include/ncursesw/form.h
/usr/include/ncursesw/tic.h
/usr/include/ncursesw/ncurses_dll.h
/usr/include/ncursesw/cursesapp.h
/usr/include/ncursesw/panel.h
/usr/include/ncursesw/cursesm.h
/usr/include/ncursesw/term.h
/usr/include/ncursesw/cursslk.h
/usr/include/ncursesw/cursesp.h
/usr/include/ncursesw/curses.h
/usr/include/ncursesw/cursesw.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libmenuw.a
/usr/lib/x86_64-linux-gnu/libncurses++w.a
/usr/lib/x86_64-linux-gnu/libncursesw.so
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/menuw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/panelw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/formw.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncurses++w.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/ncursesw.pc
/usr/lib/x86_64-linux-gnu/libncursesw.a
/usr/lib/x86_64-linux-gnu/libpanelw.a
/usr/lib/x86_64-linux-gnu/libformw.a
/usr/share/doc/libncursesw5-dev
/usr/include/ncursesw/ncurses.h
/usr/lib/x86_64-linux-gnu/libpanelw.so
/usr/lib/x86_64-linux-gnu/libformw.so
/usr/lib/x86_64-linux-gnu/libmenuw.so

which does not allow curses gem to compile. I think extconf.rb has to be adapted.

@etm
Copy link

etm commented Mar 19, 2015

Solution would be:

ext/curses/curses.c - line 25 - add:

#elif defined(HAVE_NCURSESW_CURSES_H)
# include <ncursesw/curses.h> 

ext/curses/extconf.rb - line 35 - add

["ncursesw/curses.h", ["ncursesw"]],

@etm
Copy link

etm commented Mar 23, 2015

anybody alive? I know fixing build problems is boring, but this would actually be very helpful for linux users that want curses + utf-8 (by using ncursesw).

@mcormier
Copy link
Contributor

You may want to check out https://github.com/eclubb/ncurses-ruby and see if it fixes your problems. I'm not a maintainer of this project. Just a listener.

@etm
Copy link

etm commented Mar 23, 2015

@mcormier: nope. has same problem, plus has very different api.

@etm
Copy link

etm commented Mar 23, 2015

the question is: is this issue tracker actually for issue tracking, or do we have to go through https://bugs.ruby-lang.org/?

@zzak
Copy link
Member

zzak commented Mar 23, 2015

It's possible this is a bug with your terminal or the version of ncurses you're using.

@etm
Copy link

etm commented Mar 23, 2015

@zzak: i already explained that in linux now curses with wide character support typically comes in ncursesw package, which is inlcuded through ncursesw/curses.h. I also explained the 2 small changes in order to fix it. So i'm fine :-) I just wonder if this is maintained at all.

@zzak
Copy link
Member

zzak commented Mar 23, 2015

OH I see! Sorry I missed your comment.. could you send a patch? <3

drbrain added a commit that referenced this issue Mar 16, 2016
Fix dependency for ncursesw (Fix #6)
@drbrain
Copy link
Member

drbrain commented Mar 16, 2016

Released as curses 1.0.2

@lbrito1
Copy link

lbrito1 commented Jan 28, 2019

Sorry to reopen this, but I'm getting the same problem (non-ASCII char not printed properly) with curses 1.2.7.

Ubuntu 18, en_US.UTF-8 terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants