ncurses ruby and utf-8

Discussion in 'Ruby' started by Brian Schröder, Mar 7, 2005.

  1. hello group,

    I'm writing a small application using ncurses and I wonder how to make
    it output and input utf-8 characters. I also have a readline interface
    to the program, and there I can input things like û ö ñ etc. quite
    fine, using the ncurses routines it chokes.
    I'm using the getstr(str) call for text input.

    Thanks,

    Brian

    --
    Brian Schröder
    http://ruby.brian-schroeder.de/
     
    Brian Schröder, Mar 7, 2005
    #1
    1. Advertising

  2. * Brian Schröder (Mar 07, 2005 13:40):
    > I'm writing a small application using ncurses and I wonder how to make
    > it output and input utf-8 characters. I also have a readline interface
    > to the program, and there I can input things like û ö ñ etc. quite
    > fine, using the ncurses routines it chokes. I'm using the getstr(str)
    > call for text input.


    You need ncursesw (configure --enable-widec).

    Check the archive (http://www.ruby-talk.org/) for previous discussions
    (Simon Strandgaard has done some investigation into using it from Ruby).

    The ruby-ncurses package currently doesn't support wide character
    ncurses,
    nikolai

    --
    ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
    ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
    ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Mar 7, 2005
    #2
    1. Advertising

  3. Brian Schröder

    Lee Braiden Guest

    On Monday 07 March 2005 12:48, Nikolai Weibull wrote:
    > The ruby-ncurses package currently doesn't support wide character
    > ncurses,
    > nikolai


    What is the general state of unicode support in ruby?

    --
    Lee.
     
    Lee Braiden, Mar 7, 2005
    #3
  4. * Lee Braiden (Mar 07, 2005 14:40):
    > What is the general state of unicode support in ruby?


    There is none, beyond a very hackish one for regular expression
    matching via the $KCODE variable (and -K command-line option). Ruby 2.0
    will fix this, hopefully in a wonderful way (I'm talking total coverage,
    i.e, strings, io, regexes, and so on), so that character set and
    character encoding is handled as transparently as possible (i.e, we as
    Ruby programmers don't have to lift a finger),
    nikolai

    --
    ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
    ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
    ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Mar 7, 2005
    #4
  5. Brian Schröder

    Lee Braiden Guest

    On Monday 07 March 2005 14:52, Nikolai Weibull wrote:
    > * Lee Braiden (Mar 07, 2005 14:40):
    > > What is the general state of unicode support in ruby?

    >
    > Ruby 2.0
    > will fix this, hopefully in a wonderful way (I'm talking total coverage,


    Ahh. Is there an official guess on when 2.0 will happen? Best estimate I can
    find is 2006-ish?

    --
    Lee.
     
    Lee Braiden, Mar 7, 2005
    #5
  6. * Lee Braiden (Mar 07, 2005 16:10):
    > Ahh. Is there an official guess on when 2.0 will happen? Best
    > estimate I can find is 2006-ish?


    That sounds like a wishful estimate. However, if I get the time (which
    I won't), I'll probably hack something together as a suggestion for
    Unicode support. matz has commented on some parts of the future
    semantics of Strings, but there's still a lot to figure out, I'd say,
    nikolai

    --
    ::: name: Nikolai Weibull :: aliases: pcp / lone-star / aka :::
    ::: born: Chicago, IL USA :: loc atm: Gothenburg, Sweden :::
    ::: page: www.pcppopper.org :: fun atm: gf,lps,ruby,lisp,war3 :::
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Mar 7, 2005
    #6
  7. Simon Strandgaard, Mar 7, 2005
    #7
  8. On Tue, 8 Mar 2005 01:57:37 +0900, Simon Strandgaard <> wrote:
    > On Mon, 7 Mar 2005 21:48:54 +0900, Nikolai Weibull
    > <> wrote:
    > [snip]
    > > You need ncursesw (configure --enable-widec).
    > >
    > > Check the archive (http://www.ruby-talk.org/) for previous discussions
    > > (Simon Strandgaard has done some investigation into using it from Ruby).

    >
    > I wrote a small .c wrapper for ncursesw.
    > See code here:
    > http://rubyforge.org/cgi-bin/viewcv.../buffer2/source/tui.c?rev=1.4&cvsroot=aeditor
    >
    > --
    > Simon Strandgaard


    Thank you, that is very helpfull.

    best regards,

    Brian

    --
    Brian Schröder
    http://ruby.brian-schroeder.de/
     
    Brian Schröder, Mar 8, 2005
    #8
  9. Brian Schröder

    Cs. Henk Guest

    On Mon, Mar 07, 2005 at 11:52:35PM +0900, Nikolai Weibull wrote:
    > * Lee Braiden (Mar 07, 2005 14:40):
    > > What is the general state of unicode support in ruby?

    >
    > There is none, beyond a very hackish one for regular expression


    I just wonder how is it possible that a language which originated in
    Japan doesn't support unicode & co. out of the box. They do need unicode
    for proper handling of their character sets, don't they? How is it
    possible historically that noone cared about it?

    Csaba
     
    Cs. Henk, Mar 9, 2005
    #9
  10. Brian Schröder

    Dido Sevilla Guest

    On Wed, 9 Mar 2005 13:10:02 +0900, Cs. Henk <> wrote:
    > I just wonder how is it possible that a language which originated in
    > Japan doesn't support unicode & co. out of the box. They do need unicode
    > for proper handling of their character sets, don't they?


    No. Before Unicode there were already several different ways of
    encoding Japanese text (just as we English speakers have had ASCII and
    EBCDIC in the past), and Unicode is only one of them. Apparently
    Unicode isn't even the dominant way of doing so just yet: the JIS
    encodings seem to be more popular at the moment, and there are even
    three variations of JIS (Shift-JIS is by far the most widely used for
    Japanese web pages and such, and ISO-2022-JP is most widely used for
    Japanese email, and Japanese locales on Unix/Linux use the JIS EUC
    encoding).

    See this site for more information on this complicated topic:

    http://www.cs.mcgill.ca/~aelias4/encodings.html
     
    Dido Sevilla, Mar 9, 2005
    #10
  11. Dido Sevilla ha scritto:
    > On Wed, 9 Mar 2005 13:10:02 +0900, Cs. Henk <> wrote:
    >
    >>I just wonder how is it possible that a language which originated in
    >>Japan doesn't support unicode & co. out of the box. They do need unicode
    >>for proper handling of their character sets, don't they?

    >
    >
    > No. Before Unicode there were already several different ways of
    > encoding Japanese text (just as we English speakers have had ASCII and
    > EBCDIC in the past), and Unicode is only one of them. Apparently
    > Unicode isn't even the dominant way of doing so just yet: the JIS
    > encodings seem to be more popular at the moment, and there are even
    > three variations of JIS (Shift-JIS is by far the most widely used for
    > Japanese web pages and such, and ISO-2022-JP is most widely used for
    > Japanese email, and Japanese locales on Unix/Linux use the JIS EUC
    > encoding).
    >
    > See this site for more information on this complicated topic:
    >
    > http://www.cs.mcgill.ca/~aelias4/encodings.html


    Also notice that there is an old debate about unicode *not* being good
    enough for japanese and other languages, for example:
    http://tronweb.super-nova.co.jp/unicoderevisited.html
    (I really don't understand a lot about encoding, anyway)
     
    gabriele renzi, Mar 9, 2005
    #11
  12. Brian Schröder

    Cs. Henk Guest

    On Wed, Mar 09, 2005 at 01:45:57PM +0900, Dido Sevilla wrote:
    > No. Before Unicode there were already several different ways of
    > encoding Japanese text (just as we English speakers have had ASCII and
    > EBCDIC in the past), and Unicode is only one of them. Apparently
    > Unicode isn't even the dominant way of doing so just yet: the JIS
    > encodings seem to be more popular at the moment, and there are even
    > three variations of JIS (Shift-JIS is by far the most widely used for
    > Japanese web pages and such, and ISO-2022-JP is most widely used for
    > Japanese email, and Japanese locales on Unix/Linux use the JIS EUC
    > encoding).
    >
    > See this site for more information on this complicated topic:
    >
    > http://www.cs.mcgill.ca/~aelias4/encodings.html


    This is interesting, thanks for the pointer! But then, how are these
    popular schemes supported by ruby? Isn't it possible/desirable to use a
    generic scheme which can be realized then either as unicode or as one of
    the above encodings?

    Csaba
     
    Cs. Henk, Mar 9, 2005
    #12
  13. Hi,

    In message "Re: ncurses ruby and utf-8"
    on Thu, 10 Mar 2005 08:46:50 +0900, "Cs. Henk" <> writes:

    |This is interesting, thanks for the pointer! But then, how are these
    |popular schemes supported by ruby? Isn't it possible/desirable to use a
    |generic scheme which can be realized then either as unicode or as one of
    |the above encodings?

    Ruby Regexp can handle these encodings (i.e. EUC-JP, Shift_JIS, UTF-8).

    matz.
     
    Yukihiro Matsumoto, Mar 10, 2005
    #13
  14. Simon Strandgaard wrote:
    > On Mon, 7 Mar 2005 21:48:54 +0900, Nikolai Weibull
    > <> wrote:
    > [snip]
    >
    >>You need ncursesw (configure --enable-widec).
    >>
    >>Check the archive (http://www.ruby-talk.org/) for previous discussions
    >>(Simon Strandgaard has done some investigation into using it from Ruby).

    >
    >
    >
    > I wrote a small .c wrapper for ncursesw.
    > See code here:
    > http://rubyforge.org/cgi-bin/viewcv.../buffer2/source/tui.c?rev=1.4&cvsroot=aeditor


    Looking through your wrapper, I have not recognized anything that would
    be specific to ncursesw, and differ from narrow-character ncurses (apart
    from wrapping wcwidth, which seems to live in libc).

    So I wonder what it would take to make ncurses-ruby wide-character
    compatible. Could you give me a hint where to start?

    Thanks,
    Tobias
    --
    Remove invalid parts from address to reach me.
     
    Tobias Peters, Mar 12, 2005
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jmfauth
    Replies:
    4
    Views:
    346
    jmfauth
    Oct 13, 2010
  2. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,027
    Grzegorz ¦liwiñski
    Jan 19, 2011
  3. Tobias Peters

    [ANN] ncurses-ruby-0.8

    Tobias Peters, Sep 2, 2003, in forum: Ruby
    Replies:
    0
    Views:
    111
    Tobias Peters
    Sep 2, 2003
  4. Armin Roehrl
    Replies:
    2
    Views:
    115
    Dick Davies
    Apr 19, 2004
  5. Kenneth McDonald
    Replies:
    1
    Views:
    166
    Nit Khair
    Sep 27, 2008
Loading...

Share This Page