Skip to content
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

ensure reline's encoding is used when reading inputrc character values #280

Merged
merged 1 commit into from
Apr 20, 2021
Merged

ensure reline's encoding is used when reading inputrc character values #280

merged 1 commit into from
Apr 20, 2021

Conversation

jethrodaniel
Copy link
Contributor

This change ensures we use Reline::IOGate's encoding when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
.inputrc, but your default encoding isn't set.

For example:

> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"

@olleolleolle
Copy link
Contributor

Is it possible to form a test around this behaviour?

@jethrodaniel jethrodaniel marked this pull request as draft April 14, 2021 15:17
@jethrodaniel
Copy link
Contributor Author

@olleolleolle Sounds possible - I'll add a test

This change ensures we use `Reline::IOGate`'s `encoding` when converting
characters from their integer values.

This fixes an issue that may occur if you have UTF characters in your
`.inputrc`, but your default encoding isn't set.

For example:

```
> 127864.ord.chr
RangeError: 127864 out of char range
from (pry):1:in `chr'
> Reline::IOGate.encoding
=> #<Encoding:UTF-8>
> 127864.ord.chr(Reline::IOGate.encoding)
=> "🍸"
```
@jethrodaniel jethrodaniel marked this pull request as ready for review April 15, 2021 01:06
@olleolleolle
Copy link
Contributor

Sweet test, @jethrodaniel!

@aycabta aycabta merged commit e4ac748 into ruby:master Apr 20, 2021
aycabta added a commit to aycabta/reline that referenced this pull request Apr 20, 2021
ensure reline's encoding is used when reading inputrc character values
aycabta added a commit to aycabta/reline that referenced this pull request Apr 20, 2021
In Japan, so many programmers used EUC-JP to write text files which contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This supports whole encoding what user set including UTF-8.

ref. ruby#280
aycabta added a commit to aycabta/reline that referenced this pull request Apr 20, 2021
In Japan, so many programmers used EUC-JP to write text files which contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This supports whole encoding what user set including UTF-8.

ref. ruby#280
aycabta added a commit to aycabta/reline that referenced this pull request Apr 20, 2021
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. ruby#280
@aycabta
Copy link
Member

aycabta commented Apr 20, 2021

Thank you for the patch, and I added another Pull Request to improve this point!

#283

@jethrodaniel jethrodaniel deleted the chr-encoding-issue branch April 20, 2021 14:42
matzbot pushed a commit to ruby/ruby that referenced this pull request Jun 21, 2021
In Japan, so many programmers used EUC-JP to write text files that contain
Japanese. Many .inputrc files which contain EUC-JP are still being copied and
used. This commit supports the whole encoding of what user set including UTF-8.

ref. ruby/reline#280

ruby/reline@0b45022e16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants