0

I stopped program with pry, then I type

[1] pry(Module1::Class1)> Encoding.default_external => #<Encoding:Windows-1252> 

In another mac, default value of Encoding.default_external is UTF-8. I changed locale variables to UTF-8, and encoding in irb works fine, but not in project stopped. With byebug is the same.

System is macOSX, ruby 2.3.3 through rbenv.

1
  • closed due to wrong investigation. Commented Mar 14, 2018 at 8:09

1 Answer 1

2

You can use the LANG env variable to influence the default external encoding:

ruby-2.3.4 Desktop$ LANG=en_US.US-ASCII irb 2.3.4 :001 > Encoding.default_external => #<Encoding:US-ASCII> ruby-2.3.4 Desktop$ LANG=de_CH.UTF-8 irb 2.3.4 :001 > Encoding.default_external => #<Encoding:UTF-8> 

it is also possible to override it with the -E options:

ruby-2.3.4 Desktop$ LANG=en_US.US-ASCII irb -E utf-8 2.3.4 :001 > Encoding.default_external => #<Encoding:UTF-8> 
Sign up to request clarification or add additional context in comments.

2 Comments

it works with irb, but not with project stopped with pry or byebug
How did you start this "project"? What is this "project"? Just ruby script, a Rails application? You need to make sure that the project is started with correct settings. Also: if you have CP1252 as default encoding? Where is it running, sounds like Windows?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.