8000 Allow overriding the Reline encoding · Issue #755 · ruby/reline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Allow overriding the Reline encoding #755
Closed
@sjanusz-r7

Description

@sjanusz-r7

Description

Currently the Reline library uses the Ruby's default encoding, but this is not configurable:

def encoding
Encoding.default_external
end

It would be great to configure this value, i.e. in the scenario of having the encoding set to ASCII-8BIT globally - but wanting Reline to use UTF-8 encoding:

  ::Encoding.default_external = ::Encoding::ASCII_8BIT
  ::Encoding.default_internal = ::Encoding::ASCII_8BIT

  # Workaround to fix encoding crash:
  # class ::Reline::ANSI
  #   def encoding
  #     ::Encoding::UTF_8
  #   end
  # end

  ascii_text = Reline.readline('prompt > ', false)

  $stderr.puts ascii_text.encoding.to_s

Example

Pasting in the characters こんにちは

prompt > こんにちは

Current Behaviour

Crash: gems/reline-0.5.10/lib/reline/unicode.rb:112:in 'encode': "\\xE3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

Desired Behaviour

Being able to configure the value on Reline:

  def encoding
    @encoding || Encoding.default_external
  end

Terminal Emulator

OSX

Version

0.5.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0