-
Notifications
You must be signed in to change notification settings - Fork 96
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
UTF-8 characters are not displayed / read properly on Mac OS X Snow Leopard #180
Comments
Are you using latest Sup 0.15? |
Hmm, maybe |
I'm using sup v0.15.0. |
What encoding do you have set? Typically shown before Sup starts or in ~/.sup/log. The get char stuff is a bit hacky because ncurses only gives us ASCII-8bit chars without any encoding information, so we fix_encoding! it. Check out: Also; what terminal are you using and what encoding is it set to? Does it match your SHELL encoding variables? |
Yeah, but when you do EDIT: or not :> i'll test it returning I'm collecting info you requested, 1 sec. |
The terminal emulation program is iTerm.
|
Hm, ok. I'll check later with my own Mac if the behavior is the same. I assume this is iTerm2. If you know how to fix it please do. The stuff that allows the use of old ncursesw-ruby is unnecessary and can be removed [0]. We require ncursesw and our own ncursesw gem as well as a recent ncurses library. [0] https://github.com/sup-heliotrope/sup/blob/develop/lib/sup/buffer.rb#L36 By the way, as far as I know: xterm isn't necessarily UTF8, at least on Unix. Might be that Mac OS X Snow Leopard has a termcap/info file that makes it UTF8 though. |
I've put some debug there and there are two bytes returned instead of one character code. When typing space When typing 'ą' letter (a with ogonek) |
I just found that there is |
I had simply assumed that they were the ones that were wrapped to when configured for wide chars, apparently not. If there needs to be modifications to ncursesw-sup we'll just release a new version of it along with next sup. |
For now I'm playing with Until fix in |
I was able to modify However, |
Ok, I wrapped the get_wch function ihere: sup-heliotrope/ncursesw-ruby#12 you could try and build the gem and implement it using that function. |
acutally hang on, its not complete yet.. |
Unfortunately passing decimal values of UTF-8 characters that are returned by modified |
Ok, the wrapper should be ok in sup-heliotrope/ncursesw-ruby#12 now. Does that help? |
Ok, tested. It's working ( |
I see two solutions:
|
I could also implement get_wch correctly, it returns whether it is a
|
That would be great, but will not help much since I've created small class called https://github.com/siefca/sup/tree/fix_input_multibyte_characters The real problem now is in I've found some forum posts that there is wide- version of |
Yeah, it seems you are right. See latest commit in the ncursesw pull request for where I return the key type as well. It doesn't really help, since the form_driver messes things up. |
I think formw is part of libncursesw; but you can modify extconf.rb in the gem to fail if it doesn't find it: diff --git a/extconf.rb b/extconf.rb
index 1c60bbd..74b5464 100644
--- a/extconf.rb
+++ b/extconf.rb
@@ -134,7 +134,9 @@ end
puts "checking for the form library..."
if have_header("form.h")
- have_library("formw", "new_form")
+ if not have_library("formw", "new_form")
+ raise "formw library not found"
+ end
else
raise "form library not found."
end
|
BTW, is there some version of |
Re, I'm trying to use |
I changed it to return the wide char as a Fixnum (gauteh/ncursesw-ruby@4481f31). As far as I can understand the widechar encoding depends on the input from the terminal (terminal codeset + encoding), so it should be interpreted based on that. |
Maybe we need to use the form set_field functions when it is a regular char. form_driver does not seem to have a wide char equivalent. |
By the way, does it fix your problem if you set: LibC.setlocale(6, "") # LC_ALL == 6 to: LibC.setlocale(6, "pl_PL.UTF-8") # LC_ALL == 6 in |
I can make the example |
The |
Your idea to add the char using |
Yeah. Actually form_get_wch works for Value2 on iTerm2 now. But not on Linux. |
Out of curiosity I compiled ncruses with tracing. This is for
This is for
The magic value of if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
The 'ą'.ord.to_s(2)
# => "100000101"
'ł'.ord.to_s(2)
# => "101000010"
'ó'.ord.to_s(2) # this one passes and will be displayed
# => "011110011" But that's not the end. Even if it would pass the conditional statement is then evaluated: if (!iscntrl(UChar(c))) Which fails.
|
Yeah, BTW: |
Seems that ncurses is not using |
I patched ncurses to use |
I patched ncurses to use We can assume that |
Im working on a patched version of ncurses with wide versions of both form_driver_w and Data_Entry_w, i'll push it to github in a moment with an example. |
👍 BTW, if |
Check out: gauteh/ncurses@master...form_driver_w |
For me the example I installed my version of ncurses using brew: $ brew edit ncurses and change url to: https://github.com/gauteh/ncurses/archive/form_driver_w.zip (comment out mirror and sha1s). $ brew reinstall ncurses
$ brew link ncurses --force Then check out the branch above; build and install the gem; and test the form_get_wch.rb script. Since it is relatively easy to use this version of Ncurses through brew we might just check in Sup whether form_driver_w is available, use it or otherwise fall back to form_driver. |
Ok, installed. Checking how sup will integrate. |
Cool, now it remains to see if get_cursed_value returns something sensible.. 😀 |
Ok, I moved some stuff to another file. I'll check it after I eat something. |
|
I have submitted form_driver_w upstream, there may be no hope of it getting merged, in which case form_driver_w patched into the brew recipe in Mac OS X might be a workaround that people have to do.
|
Ok, ok. |
I have a strange problem in testing if require 'ncursesw'
require 'sup/util'
p Ncurses::Form.form_driver gives:
|
The function isnt defined before after init has been called on Ncurses.
|
Ok, I'll create checker module method and call it after initscr. |
Ok. Buffer is now form_driver_w-ized. |
Nice coding with you. Thanks! |
Does it work without NCURSES_OPAQUE set? https://github.com/sup-heliotrope/ncursesw-ruby/blob/master/extconf.rb#L154 |
It's working (diacritics), but on Mac OS enabling NCURSES_OPAQUE causes lags during loading threads. |
Fixed in 7e7858c. |
Hi,
I'm using Mac OS X Snow Leopard and Ruby 1.9.3-p448 with ncurses library v5.9 from https://github.com/homebrew/homebrew-dupes/commits/master/ncurses.rb
I followed the installation instructions from Wiki. Everything works great but I am unable to enter any UTF-8 character into text line in sup (searching, entering Subject, To or other lines etc.). UTF-8 characters in "pager" (i.e. inbox mode and when viewing messages) are properly displayed; there is a problem with input line.
I thought that's something with input handling (meta key) but copying and pasting UTF-8 characters also generates mojibakes (unreadable characters):
BTW, ViM and other tools – like irb for instance – compiled with the same ncurses library are displaying characters properly.
Please help me and save all the pandas from around the world. :]
PS: I changed
scroll_mode.rb
a bit and put UTF-8 character into prompt – it's displayed properly:The text was updated successfully, but these errors were encountered: