Skip to content

Conversation

@porras
Copy link

@porras porras commented Nov 14, 2025

Output was already fine. So I think this is all that's needed to support Unicode. It is testable with example/input.cr. I also used this example to test, that in the end I didn't include in the PR because it's so similar to the one there's already in the repository:

require "./../src/ncurses"

NCurses.start
NCurses.cbreak
NCurses.no_echo
NCurses.no_timeout
NCurses.keypad true

NCurses.print "Type any char (including Unicode like Ñ or 💃)", 2, 10
NCurses.print "Q or 🚪 to exit", 3, 15
NCurses.move 5, 15

NCurses.refresh

NCurses.get_char do |ch|
  break if ch.is_a?(Char) && "Q🚪".includes?(ch)
  NCurses.print(ch.inspect, 5, 15)
  NCurses.clear_to_eol
  NCurses.refresh
end

NCurses.end

Of course, it would be possible to add this method with a different name instead of replacing it, but I thought this would be ok because it's backwards compatible (obviously works with ASCII input) and it just makes sense in a language like Crystal that supports Unicode by default. Let me know if you think that having an additional get_char_w or something like that would be better.

This is the only method currently implemented that would need to change if I'm not mistaken. I thought of adding wget_wstr, but since wgettstr is not implemented, I left it so.

Fixes #13.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unicode input

1 participant