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

Include Unicode version in east_asian_width.rb #438

Closed
elfham opened this issue Mar 17, 2022 · 0 comments · Fixed by #586
Closed

Include Unicode version in east_asian_width.rb #438

elfham opened this issue Mar 17, 2022 · 0 comments · Fixed by #586
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@elfham
Copy link
Contributor

elfham commented Mar 17, 2022

Description

How about including the Unicode version information in lib/reline/unicode/east_asian_width.rb?

for example...

Proposal A

Specify Unicode verison by command line argument.

% diff bin/generate_east_asian_width.orig bin/generate_east_asian_width
4c4
<   puts 'bin/generate_east_asian_width path-to-EastAsianWidth.txt'
---
>   puts 'bin/generate_east_asian_width path-to-EastAsianWidth.txt [ UnicodeVersion ]'
7a8,9
> unicode_version = ARGV[1]
>
51c53
<   # #{ARGV.first}
---
>   # #{ARGV.first}#{unicode_version ? " (Unicode #{unicode_version})" : ""}
% ./bin/generate_east_asian_width EastAsianWidth.txt | grep East
class Reline::Unicode::EastAsianWidth
  # This is based on EastAsianWidth.txt
  # EastAsianWidth.txt
% ./bin/generate_east_asian_width EastAsianWidth.txt 14.0.0 | grep East
class Reline::Unicode::EastAsianWidth
  # This is based on EastAsianWidth.txt
  # EastAsianWidth.txt (Unicode 14.0.0)
%

Proposal B

use OpenURI.

% diff bin/generate_east_asian_width.orig bin/generate_east_asian_width
2a3,4
> require 'open-uri'
>
8c10,12
< open(ARGV.first, 'rt') do |f|
---
> mode_enc = (/\Ahttps?:/ =~ ARGV.first) ? 'r' : 'rt'  # XXX open-uri bug?
>
> URI.open(ARGV.first, mode_enc) do |f|
% ./bin/generate_east_asian_width EastAsianWidth.txt | grep East
class Reline::Unicode::EastAsianWidth
  # This is based on EastAsianWidth.txt
  # EastAsianWidth.txt
% ./bin/generate_east_asian_width http://ftp.unicode.org/Public/14.0.0/ucd/EastAsianWidth.txt | grep East
class Reline::Unicode::EastAsianWidth
  # This is based on EastAsianWidth.txt
  # http://ftp.unicode.org/Public/14.0.0/ucd/EastAsianWidth.txt
%
@ima1zumi ima1zumi added enhancement New feature or request good first issue Good for newcomers labels Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

Successfully merging a pull request may close this issue.

2 participants