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

Unicode support? #35

Open
saethlin opened this issue Feb 24, 2018 · 7 comments
Open

Unicode support? #35

saethlin opened this issue Feb 24, 2018 · 7 comments

Comments

@saethlin
Copy link

It looks to me like ncurses-sys and pdcurses-sys both have unicode support, but I can't figure out how to enable it here. Is this a planned feature?

@ihalila
Copy link
Owner

ihalila commented Feb 25, 2018

Could you elaborate on what you mean exactly? At least on Windows unicode output works as far as I know, aside from some special cases, and input should as well for both platforms with the release of v0.15. Output with ncurses may require more work, I haven't looked into it for a while.

@saethlin
Copy link
Author

saethlin commented Feb 25, 2018

I'm looking at a problem with unicode output on linux.

I think all one would need is to insert this call after the initscr() call, but I'm a bit hesitant to suggest just making everyone en-US locale.
https://github.com/jeaye/ncurses-rs/blob/85ab2aa9d58eb58ba68cbac47f105cc93cf36aae/examples/ex_7.rs#L19

@ihalila
Copy link
Owner

ihalila commented Feb 25, 2018

setlocale is already called in

setlocale(LcCategory::all, "");
, so that's not the problem.

I did some testing and Unicode output works as it should for me as long as I have the ncurses/wide feature enabled (exported as just wide in pancurses) and I don't use addch, because that doesn't work correctly. Checking the ncurses manual at http://invisible-island.net/ncurses/man/curs_addch.3x.html it has two relevant bullet points:

  • check if a character can be represented as a single byte in the current locale before attempting call waddch, and
  • call wadd_wch for characters which cannot be handled by waddch.

which leads me to believe that pancurses should really always use wadd_wch, it would probably work correctly. Unfortunately ncurses-rs does not expose that function yet so fixing this requires a change there first.

@saethlin
Copy link
Author

I added features = ["wide"] to my Cargo.toml, and unicode output works now!
Is there still work to be done? If this feature is incomplete or something I'm interested in helping out.

@ihalila
Copy link
Owner

ihalila commented Feb 25, 2018

The only issue I know of is the one I described in my earlier comment, regarding addch() not working for multibyte characters.

@TimonPost
Copy link

There is one other problem as described here:

#43 (comment)

We can't use Unicode on a terminal created with pancurses::newterm. In order to support this platform_specific::pre_init() should be added to that function as well.

@plefebvre91
Copy link

Is there any solution today ?

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

No branches or pull requests

4 participants