Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Incorrect encoding for interactive input #843

Crossverse opened this Issue · 8 comments

4 participants



In Pry when i type dd="string" i'll get dd.encoding =>ASCII-8bit and its wrong.

In IRB dd.encoding =>"IBM866" and it 's true.

STDIN.external_encoding in both case =>"IBM866".

1) Can you resilve problem?
2) Is it possible to configure default encoding of typed strings in Pry?


Could you provide some information about your environment? Also, I cannot reproduce your bug. Are there any special cases I need to pay attention to?


GD! I have win8 environment. Default windows encoding 'cp1251'. default console encoding 'ibm866'. when i use only latin characters the encoding of strings is 'US-ASCII'. when i use russian symbols i get 'ASCII-8BIT' encoding.

simple way to reproduce encoding following. in pry interactive input.
[1] pry(main)> r="rrr"
=> "rrr"
[2] pry(main)> r.encoding
=> #Encoding:US-ASCII
[3] pry(main)> r="ююю"
=> "\xEE\xEE\xEE"
[4] pry(main)> r.encoding
=> #Encoding:ASCII-8BIT
[5] pry(main)>


It seems that rbreadline return incorrect encoding for non-latin strings. (may be rbreadline work only with latin and some japan encodings)


Hi! When you refer to the default Windows encoding and default terminal encoding, where is this set? What does it affect? What do you expect Pry to be doing? Does a normal Ruby program respond to those settings?



console ruby programms correctly know external encoding (f.e. ibm866). i expect that encoding of strings with non latin symbols that was input in interactive pry must be 'ibm866'. its worked normal in irb and as i understand it is normal ruby program behaviour (encoding of input strings must be external encoding, but for interactive pry it is not work correctly)


@Crossverse, sorry, but how is that possible that you use Russian letters in IRB or Pry? This is what I get (question marks instead of Russian letters).


@Crossverse, never mind. :-P

I can reproduce the issue.

@kyrylo kyrylo was assigned

The problem is that Readline.readline always returns ASCII strings on windows. You can "hack" a fix with:

Pry.hooks.add_hook :after_read, :hack_encoding do |str, _|
  str.force_encoding STDIN.external_encoding 

We should probably file this bug in ruby itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.