Created
September 10, 2015 03:43
-
-
Save abinoam/c8e81f7c0e851bee40f4 to your computer and use it in GitHub Desktop.
RbReadline multibyte support test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
# This will remove old Readline if it's already defined | |
require 'rb-readline' | |
# This will load RbReadline for real | |
require 'rbreadline' | |
# This will load Readline that relies on RbReadline | |
require 'readline' | |
Readline.completion_proc = lambda do |str| | |
[ "pure_ascii", "with_utf_8_characters_like_ã_and_ç" ].grep(/\A#{Regexp.escape(str)}/) | |
end | |
line = Readline.readline("> ", false) | |
puts "Got: #{line}" | |
STDOUT.puts "RbReadline::RB_READLINE_VERSION #{RbReadline::RB_READLINE_VERSION}" | |
STDOUT.puts "Readline::VERSION #{Readline::VERSION}" | |
STDOUT.puts "RUBY_DESCRIPTION #{RUBY_DESCRIPTION}" |
I got this on my Mac:
> with_utf_8_characters_like_ã_and_çrbreadline.rb:13:in `===': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (Encoding::CompatibilityError)
from rbreadline.rb:13:in `each'
from rbreadline.rb:13:in `grep'
from rbreadline.rb:13:in `block in <main>'
from /Users/dberger/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rb-readline-0.5.3/lib/readline.rb:136:in `call'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My output is when I try to autocomplete with tab the
"with_utf_8_characters_like_ã_and_ç"
string is bellow: