Skip to content

Set EastAsianWidth::UNICODE_VERSION#586

Merged
ima1zumi merged 3 commits intoruby:masterfrom
elfham:eaw-version
Aug 29, 2023
Merged

Set EastAsianWidth::UNICODE_VERSION#586
ima1zumi merged 3 commits intoruby:masterfrom
elfham:eaw-version

Conversation

@elfham
Copy link
Copy Markdown
Contributor

@elfham elfham commented Aug 24, 2023

fix #438

The beginning of the comment in EastAsianWidth.txt contains the Unicode version.

% head -3 EastAsianWidth.txt
# EastAsianWidth-15.0.0.txt
# Date: 2022-05-24, 17:40:20 GMT [KW, LI]
# © 2022 Unicode®, Inc.
% 

At least since Unicode 3.2.0, the version seems to be included.

% curl --silent https://www.unicode.org/Public/3.2-Update/EastAsianWidth-3.2.0.txt | head -3
# EastAsianWidth-3.2.0.txt
#
# East Asian Width Properties
%

So, the version is retrieved from there.

% ruby bin/generate_east_asian_width EastAsianWidth.txt | head
class Reline::Unicode::EastAsianWidth
  # This is based on EastAsianWidth.txt
  # EastAsianWidth.txt
  UNICODE_VERSION = '15.0.0'

  # Fullwidth
  TYPE_F = /^[#{ %W(
    \u{3000}
    \u{FF01}-\u{FF60}
    \u{FFE0}-\u{FFE6}
%

The version is set to Reline::Unicode::EastAsianWidth::UNICODE_VERSION.

The variable name UNICODE_VERSION is taken from RbConfig::CONFIG["UNICODE_VERSION"].

If the comment format is changed in the future and the Unicode version fails to be retrieved, a warning will be displayed and set UNICODE_VERSION = nil.

% ruby bin/generate_east_asian_width <(tail +2 EastAsianWidth.txt) > /dev/null
Failed to get UNICODE_VERSION
% ruby bin/generate_east_asian_width <(tail +2 EastAsianWidth.txt) | grep UNICODE_VERSION
Failed to get UNICODE_VERSION
  UNICODE_VERSION = nil
% 

Comment thread lib/reline/unicode/east_asian_width.rb Outdated
class Reline::Unicode::EastAsianWidth
# This is based on EastAsianWidth.txt
# EastAsianWidth.txt
UNICODE_VERSION = '15.0.0'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this constant is not used in Reline, why not leave it as a comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I fixed the code that way.

Copy link
Copy Markdown
Member

@ima1zumi ima1zumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ima1zumi ima1zumi merged commit 6d94f2a into ruby:master Aug 29, 2023
matzbot pushed a commit to ruby/ruby that referenced this pull request Aug 29, 2023
(ruby/reline#586)

* Set EastAsianWidth::UNICODE_VERSION

* Commented out UNICODE_VERSION in Reline::Unicode::EastAsianWidth

* Commented out UNICODE_VERSION in Reline::Unicode::EastAsianWidth

ruby/reline@6d94f2a26a
@elfham elfham deleted the eaw-version branch August 30, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include Unicode version in east_asian_width.rb

2 participants