unicode-eaw 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/unicode/eaw/data.rb +7 -0
- data/lib/unicode/eaw/version.rb +5 -0
- data/lib/unicode/eaw.rb +40 -0
- data/tools/generate.rb +60 -0
- data/unicode-eaw.gemspec +29 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: becf526d7b10aa2e5346b4df00dd720257219948b34b058bed41a0325904d759
|
4
|
+
data.tar.gz: f308d3fc0bf777a083a7e327578e198a2edcdaf5207a9f6fd598476ffb94e59d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb09e177d7c9f2afb573e2a15846aace1caaa33da442a40b3f0a35f70c25fd5e802e2de8016df2921242fe21f796db347bf1cb4d7cdcc649c7947b089b21160e
|
7
|
+
data.tar.gz: '08900013cc1f1df817146c429469485d8561a4cec73d6ca1a21e7461add1f4af92c55ab83d60de3c707b2cdf7b9e7422184a897fc976166d79c442b3e1c435cb'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2019 Masayoshi Takahashi (@takahashim)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Unicode::Eaw
|
2
|
+
|
3
|
+
[Unicode East Asian Width data](https://www.unicode.org/reports/tr11/) for Ruby
|
4
|
+
|
5
|
+
This library is a port of [easta](https://github.com/teppeis/easta) for Node.js.
|
6
|
+
|
7
|
+
Support Unicode version: [12.1.0](https://www.unicode.org/Public/12.1.0/ucd/EastAsianWidth.txt)
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'unicode-eaw'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install unicode-eaw
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Unicode::Eaw.width('A') #=> :Na ## Narrow
|
30
|
+
Unicode::Eaw.width('A') #=> :F ## Fullwidth
|
31
|
+
Unicode::Eaw.width('ア') #=> :W ## Wide
|
32
|
+
Unicode::Eaw.width('ア') #=> :H ## Halfwidth
|
33
|
+
Unicode::Eaw.width('α') #=> :A ## Ambiguous
|
34
|
+
Unicode::Eaw.width('À') #=> :N ## Neutral
|
35
|
+
```
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
40
|
+
|
41
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/takahashim/unicode-eaw.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "unicode/eaw"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## EastAsianWidth-12.1.0.txt
|
2
|
+
module Unicode
|
3
|
+
module Eaw
|
4
|
+
DATA=[[0,0,31],[1,32,94],[0,127,33],[2,161],[1,162,1],[2,164],[1,165,1],[2,167,1],[0,169],[2,170],[0,171],[1,172],[2,173,1],[1,175],[2,176,4],[0,181],[2,182,4],[0,187],[2,188,3],[0,192,5],[2,198],[0,199,8],[2,208],[0,209,5],[2,215,1],[0,217,4],[2,222,3],[0,226,3],[2,230],[0,231],[2,232,2],[0,235],[2,236,1],[0,238,1],[2,240],[0,241],[2,242,1],[0,244,2],[2,247,3],[0,251],[2,252],[0,253],[2,254],[0,255,1],[2,257],[0,258,14],[2,273],[0,274],[2,275],[0,276,6],[2,283],[0,284,9],[2,294,1],[0,296,2],[2,299],[0,300,4],[2,305,2],[0,308,3],[2,312],[0,313,5],[2,319,3],[0,323],[2,324],[0,325,2],[2,328,3],[0,332],[2,333],[0,334,3],[2,338,1],[0,340,17],[2,358,1],[0,360,2],[2,363],[0,364,97],[2,462],[0,463],[2,464],[0,465],[2,466],[0,467],[2,468],[0,469],[2,470],[0,471],[2,472],[0,473],[2,474],[0,475],[2,476],[0,477,115],[2,593],[0,594,14],[2,609],[0,610,97],[2,708],[0,709,1],[2,711],[0,712],[2,713,2],[0,716],[2,717],[0,718,1],[2,720],[0,721,6],[2,728,3],[0,732],[2,733],[0,734],[2,735],[0,736,31],[2,768,111],[0,880,7],[0,890,5],[0,900,6],[0,908],[0,910,2],[2,913,16],[2,931,6],[0,938,6],[2,945,16],[0,962],[2,963,6],[0,970,54],[2,1025],[0,1026,13],[2,1040,63],[0,1104],[2,1105],[0,1106,221],[0,1329,37],[0,1369,49],[0,1421,2],[0,1425,54],[0,1488,26],[0,1519,5],[0,1536,28],[0,1566,239],[0,1807,59],[0,1869,100],[0,1984,58],[0,2045,48],[0,2096,14],[0,2112,27],[0,2142],[0,2144,10],[0,2208,20],[0,2230,7],[0,2259,176],[0,2437,7],[0,2447,1],[0,2451,21],[0,2474,6],[0,2482],[0,2486,3],[0,2492,8],[0,2503,1],[0,2507,3],[0,2519],[0,2524,1],[0,2527,4],[0,2534,24],[0,2561,2],[0,2565,5],[0,2575,1],[0,2579,21],[0,2602,6],[0,2610,1],[0,2613,1],[0,2616,1],[0,2620],[0,2622,4],[0,2631,1],[0,2635,2],[0,2641],[0,2649,3],[0,2654],[0,2662,16],[0,2689,2],[0,2693,8],[0,2703,2],[0,2707,21],[0,2730,6],[0,2738,1],[0,2741,4],[0,2748,9],[0,2759,2],[0,2763,2],[0,2768],[0,2784,3],[0,2790,11],[0,2809,6],[0,2817,2],[0,2821,7],[0,2831,1],[0,2835,21],[0,2858,6],[0,2866,1],[0,2869,4],[0,2876,8],[0,2887,1],[0,2891,2],[0,2902,1],[0,2908,1],[0,2911,4],[0,2918,17],[0,2946,1],[0,2949,5],[0,2958,2],[0,2962,3],[0,2969,1],[0,2972],[0,2974,1],[0,2979,1],[0,2984,2],[0,2990,11],[0,3006,4],[0,3014,2],[0,3018,3],[0,3024],[0,3031],[0,3046,20],[0,3072,12],[0,3086,2],[0,3090,22],[0,3114,15],[0,3133,7],[0,3142,2],[0,3146,3],[0,3157,1],[0,3160,2],[0,3168,3],[0,3174,9],[0,3191,21],[0,3214,2],[0,3218,22],[0,3242,9],[0,3253,4],[0,3260,8],[0,3270,2],[0,3274,3],[0,3285,1],[0,3294],[0,3296,3],[0,3302,9],[0,3313,1],[0,3328,3],[0,3333,7],[0,3342,2],[0,3346,50],[0,3398,2],[0,3402,5],[0,3412,15],[0,3430,25],[0,3458,1],[0,3461,17],[0,3482,23],[0,3507,8],[0,3517],[0,3520,6],[0,3530],[0,3535,5],[0,3542],[0,3544,7],[0,3558,9],[0,3570,2],[0,3585,57],[0,3647,28],[0,3713,1],[0,3716],[0,3718,4],[0,3724,23],[0,3749],[0,3751,22],[0,3776,4],[0,3782],[0,3784,5],[0,3792,9],[0,3804,3],[0,3840,71],[0,3913,35],[0,3953,38],[0,3993,35],[0,4030,14],[0,4046,12],[0,4096,197],[0,4295],[0,4301],[0,4304,47],[3,4352,95],[0,4448,232],[0,4682,3],[0,4688,6],[0,4696],[0,4698,3],[0,4704,40],[0,4746,3],[0,4752,32],[0,4786,3],[0,4792,6],[0,4800],[0,4802,3],[0,4808,14],[0,4824,56],[0,4882,3],[0,4888,66],[0,4957,31],[0,4992,25],[0,5024,85],[0,5112,5],[0,5120,668],[0,5792,88],[0,5888,12],[0,5902,6],[0,5920,22],[0,5952,19],[0,5984,12],[0,5998,2],[0,6002,1],[0,6016,93],[0,6112,9],[0,6128,9],[0,6144,14],[0,6160,9],[0,6176,88],[0,6272,42],[0,6320,69],[0,6400,30],[0,6432,11],[0,6448,11],[0,6464],[0,6468,41],[0,6512,4],[0,6528,43],[0,6576,25],[0,6608,10],[0,6622,61],[0,6686,64],[0,6752,28],[0,6783,10],[0,6800,9],[0,6816,13],[0,6832,14],[0,6912,75],[0,6992,44],[0,7040,115],[0,7164,59],[0,7227,14],[0,7245,59],[0,7312,42],[0,7357,10],[0,7376,42],[0,7424,249],[0,7675,282],[0,7960,5],[0,7968,37],[0,8008,5],[0,8016,7],[0,8025],[0,8027],[0,8029],[0,8031,30],[0,8064,52],[0,8118,14],[0,8134,13],[0,8150,5],[0,8157,18],[0,8178,2],[0,8182,8],[0,8192,15],[2,8208],[0,8209,1],[2,8211,3],[0,8215],[2,8216,1],[0,8218,1],[2,8220,1],[0,8222,1],[2,8224,2],[0,8227],[2,8228,3],[0,8232,7],[2,8240],[0,8241],[2,8242,1],[0,8244],[2,8245],[0,8246,4],[2,8251],[0,8252,1],[2,8254],[0,8255,37],[0,8294,11],[2,8308],[0,8309,9],[2,8319],[0,8320],[2,8321,3],[0,8325,9],[0,8336,12],[0,8352,8],[4,8361],[0,8362,1],[2,8364],[0,8365,18],[0,8400,32],[0,8448,2],[2,8451],[0,8452],[2,8453],[0,8454,2],[2,8457],[0,8458,8],[2,8467],[0,8468,1],[2,8470],[0,8471,9],[2,8481,1],[0,8483,2],[2,8486],[0,8487,3],[2,8491],[0,8492,38],[2,8531,1],[0,8533,5],[2,8539,3],[0,8543],[2,8544,11],[0,8556,3],[2,8560,9],[0,8570,14],[2,8585],[0,8586,1],[2,8592,9],[0,8602,29],[2,8632,1],[0,8634,23],[2,8658],[0,8659],[2,8660],[0,8661,17],[2,8679],[0,8680,23],[2,8704],[0,8705],[2,8706,1],[0,8708,2],[2,8711,1],[0,8713,1],[2,8715],[0,8716,2],[2,8719],[0,8720],[2,8721],[0,8722,2],[2,8725],[0,8726,3],[2,8730],[0,8731,1],[2,8733,3],[0,8737,1],[2,8739],[0,8740],[2,8741],[0,8742],[2,8743,5],[0,8749],[2,8750],[0,8751,4],[2,8756,3],[0,8760,3],[2,8764,1],[0,8766,9],[2,8776],[0,8777,2],[2,8780],[0,8781,4],[2,8786],[0,8787,12],[2,8800,1],[0,8802,1],[2,8804,3],[0,8808,1],[2,8810,1],[0,8812,1],[2,8814,1],[0,8816,17],[2,8834,1],[0,8836,1],[2,8838,1],[0,8840,12],[2,8853],[0,8854,2],[2,8857],[0,8858,10],[2,8869],[0,8870,24],[2,8895],[0,8896,81],[2,8978],[0,8979,6],[3,8986,1],[0,8988,12],[3,9001,1],[0,9003,189],[3,9193,3],[0,9197,2],[3,9200],[0,9201,1],[3,9203],[0,9204,50],[0,9280,10],[2,9312,137],[0,9450],[2,9451,96],[0,9548,3],[2,9552,35],[0,9588,11],[2,9600,15],[0,9616,1],[2,9618,3],[0,9622,9],[2,9632,1],[0,9634],[2,9635,6],[0,9642,7],[2,9650,1],[0,9652,1],[2,9654,1],[0,9656,3],[2,9660,1],[0,9662,1],[2,9664,1],[0,9666,3],[2,9670,2],[0,9673,1],[2,9675],[0,9676,1],[2,9678,3],[0,9682,15],[2,9698,3],[0,9702,8],[2,9711],[0,9712,12],[3,9725,1],[0,9727,5],[2,9733,1],[0,9735,1],[2,9737],[0,9738,3],[2,9742,1],[0,9744,3],[3,9748,1],[0,9750,5],[2,9756],[0,9757],[2,9758],[0,9759,32],[2,9792],[0,9793],[2,9794],[0,9795,4],[3,9800,11],[0,9812,11],[2,9824,1],[0,9826],[2,9827,2],[0,9830],[2,9831,3],[0,9835],[2,9836,1],[0,9838],[2,9839],[0,9840,14],[3,9855],[0,9856,18],[3,9875],[0,9876,9],[2,9886,1],[0,9888],[3,9889],[0,9890,7],[3,9898,1],[0,9900,16],[3,9917,1],[2,9919],[0,9920,3],[3,9924,1],[2,9926,7],[3,9934],[2,9935,4],[3,9940],[2,9941,12],[0,9954],[2,9955],[0,9956,3],[2,9960,1],[3,9962],[2,9963,6],[3,9970,1],[2,9972],[3,9973],[2,9974,3],[3,9978],[2,9979,1],[3,9981],[2,9982,1],[0,9984,4],[3,9989],[0,9990,3],[3,9994,1],[0,9996,27],[3,10024],[0,10025,19],[2,10045],[0,10046,13],[3,10060],[0,10061],[3,10062],[0,10063,3],[3,10067,2],[0,10070],[3,10071],[0,10072,29],[2,10102,9],[0,10112,20],[3,10133,2],[0,10136,23],[3,10160],[0,10161,13],[3,10175],[0,10176,37],[1,10214,7],[0,10222,406],[1,10629,1],[0,10631,403],[3,11035,1],[0,11037,50],[3,11088],[0,11089,3],[3,11093],[2,11094,3],[0,11098,25],[0,11126,31],[0,11160,150],[0,11312,46],[0,11360,147],[0,11513,44],[0,11559],[0,11565],[0,11568,55],[0,11631,1],[0,11647,23],[0,11680,6],[0,11688,6],[0,11696,6],[0,11704,6],[0,11712,6],[0,11720,6],[0,11728,6],[0,11736,6],[0,11744,111],[3,11904,25],[3,11931,88],[3,12032,213],[3,12272,11],[5,12288],[3,12289,61],[0,12351],[3,12353,85],[3,12441,102],[3,12549,42],[3,12593,93],[3,12688,42],[3,12736,35],[3,12784,46],[3,12832,39],[2,12872,7],[3,12880,7023],[0,19904,63],[3,19968,22156],[3,42128,54],[0,42192,347],[0,42560,183],[0,42752,191],[0,42946,4],[0,42999,52],[0,43056,9],[0,43072,55],[0,43136,69],[0,43214,11],[0,43232,115],[0,43359],[3,43360,28],[0,43392,77],[0,43471,10],[0,43486,32],[0,43520,54],[0,43584,13],[0,43600,9],[0,43612,102],[0,43739,27],[0,43777,5],[0,43785,5],[0,43793,5],[0,43808,6],[0,43816,6],[0,43824,55],[0,43888,125],[0,44016,9],[3,44032,11171],[0,55216,22],[0,55243,48],[0,55296,2047],[2,57344,6399],[3,63744,511],[0,64256,6],[0,64275,4],[0,64285,25],[0,64312,4],[0,64318],[0,64320,1],[0,64323,1],[0,64326,123],[0,64467,364],[0,64848,63],[0,64914,53],[0,65008,13],[2,65024,15],[3,65040,9],[0,65056,15],[3,65072,34],[3,65108,18],[3,65128,3],[0,65136,4],[0,65142,134],[0,65279],[5,65281,95],[4,65377,93],[4,65474,5],[4,65482,5],[4,65490,5],[4,65498,2],[5,65504,6],[4,65512,6],[0,65529,3],[2,65533],[0,65536,11],[0,65549,25],[0,65576,18],[0,65596,1],[0,65599,14],[0,65616,13],[0,65664,122],[0,65792,2],[0,65799,44],[0,65847,87],[0,65936,11],[0,65952],[0,66000,45],[0,66176,28],[0,66208,48],[0,66272,27],[0,66304,35],[0,66349,29],[0,66384,42],[0,66432,29],[0,66463,36],[0,66504,13],[0,66560,157],[0,66720,9],[0,66736,35],[0,66776,35],[0,66816,39],[0,66864,51],[0,66927],[0,67072,310],[0,67392,21],[0,67424,7],[0,67584,5],[0,67592],[0,67594,43],[0,67639,1],[0,67644],[0,67647,22],[0,67671,71],[0,67751,8],[0,67808,18],[0,67828,1],[0,67835,32],[0,67871,26],[0,67903],[0,67968,55],[0,68028,19],[0,68050,49],[0,68101,1],[0,68108,7],[0,68117,2],[0,68121,28],[0,68152,2],[0,68159,9],[0,68176,8],[0,68192,63],[0,68288,38],[0,68331,11],[0,68352,53],[0,68409,28],[0,68440,26],[0,68472,25],[0,68505,3],[0,68521,6],[0,68608,72],[0,68736,50],[0,68800,50],[0,68858,45],[0,68912,9],[0,69216,30],[0,69376,39],[0,69424,41],[0,69600,22],[0,69632,77],[0,69714,29],[0,69759,66],[0,69837],[0,69840,24],[0,69872,9],[0,69888,52],[0,69942,16],[0,69968,38],[0,70016,77],[0,70096,15],[0,70113,19],[0,70144,17],[0,70163,43],[0,70272,6],[0,70280],[0,70282,3],[0,70287,14],[0,70303,10],[0,70320,58],[0,70384,9],[0,70400,3],[0,70405,7],[0,70415,1],[0,70419,21],[0,70442,6],[0,70450,1],[0,70453,4],[0,70459,9],[0,70471,1],[0,70475,2],[0,70480],[0,70487],[0,70493,6],[0,70502,6],[0,70512,4],[0,70656,89],[0,70747],[0,70749,2],[0,70784,71],[0,70864,9],[0,71040,53],[0,71096,37],[0,71168,68],[0,71248,9],[0,71264,12],[0,71296,56],[0,71360,9],[0,71424,26],[0,71453,14],[0,71472,15],[0,71680,59],[0,71840,82],[0,71935],[0,72096,7],[0,72106,45],[0,72154,10],[0,72192,71],[0,72272,82],[0,72384,56],[0,72704,8],[0,72714,44],[0,72760,13],[0,72784,28],[0,72816,31],[0,72850,21],[0,72873,13],[0,72960,6],[0,72968,1],[0,72971,43],[0,73018],[0,73020,1],[0,73023,8],[0,73040,9],[0,73056,5],[0,73063,1],[0,73066,36],[0,73104,1],[0,73107,5],[0,73120,9],[0,73440,24],[0,73664,49],[0,73727,922],[0,74752,110],[0,74864,4],[0,74880,195],[0,77824,1070],[0,78896,8],[0,82944,582],[0,92160,568],[0,92736,30],[0,92768,9],[0,92782,1],[0,92880,29],[0,92912,5],[0,92928,69],[0,93008,9],[0,93019,6],[0,93027,20],[0,93053,18],[0,93760,90],[0,93952,74],[0,94031,56],[0,94095,16],[3,94176,3],[3,94208,6135],[3,100352,754],[3,110592,286],[3,110928,2],[3,110948,3],[3,110960,395],[0,113664,106],[0,113776,12],[0,113792,8],[0,113808,9],[0,113820,7],[0,118784,245],[0,119040,38],[0,119081,191],[0,119296,69],[0,119520,19],[0,119552,86],[0,119648,24],[0,119808,84],[0,119894,70],[0,119966,1],[0,119970],[0,119973,1],[0,119977,3],[0,119982,11],[0,119995],[0,119997,6],[0,120005,64],[0,120071,3],[0,120077,7],[0,120086,6],[0,120094,27],[0,120123,3],[0,120128,4],[0,120134],[0,120138,6],[0,120146,339],[0,120488,291],[0,120782,701],[0,121499,4],[0,121505,14],[0,122880,6],[0,122888,16],[0,122907,6],[0,122915,1],[0,122918,4],[0,123136,44],[0,123184,13],[0,123200,9],[0,123214,1],[0,123584,57],[0,123647],[0,124928,196],[0,125127,15],[0,125184,75],[0,125264,9],[0,125278,1],[0,126065,67],[0,126209,60],[0,126464,3],[0,126469,26],[0,126497,1],[0,126500],[0,126503],[0,126505,9],[0,126516,3],[0,126521],[0,126523],[0,126530],[0,126535],[0,126537],[0,126539],[0,126541,2],[0,126545,1],[0,126548],[0,126551],[0,126553],[0,126555],[0,126557],[0,126559],[0,126561,1],[0,126564],[0,126567,3],[0,126572,6],[0,126580,3],[0,126585,3],[0,126590],[0,126592,9],[0,126603,16],[0,126625,2],[0,126629,4],[0,126635,16],[0,126704,1],[0,126976,3],[3,126980],[0,126981,38],[0,127024,99],[0,127136,14],[0,127153,14],[0,127169,13],[3,127183],[0,127185,36],[2,127232,10],[0,127243,1],[2,127248,29],[0,127278,1],[2,127280,57],[0,127338,2],[2,127344,29],[3,127374],[2,127375,1],[3,127377,9],[2,127387,17],[0,127462,25],[3,127488,2],[3,127504,43],[3,127552,8],[3,127568,1],[3,127584,5],[3,127744,32],[0,127777,11],[3,127789,8],[0,127798],[3,127799,69],[0,127869],[3,127870,21],[0,127892,11],[3,127904,42],[0,127947,3],[3,127951,4],[0,127956,11],[3,127968,16],[0,127985,2],[3,127988],[0,127989,2],[3,127992,70],[0,128063],[3,128064],[0,128065],[3,128066,186],[0,128253,1],[3,128255,62],[0,128318,12],[3,128331,3],[0,128335],[3,128336,23],[0,128360,17],[3,128378],[0,128379,25],[3,128405,1],[0,128407,12],[3,128420],[0,128421,85],[3,128507,84],[0,128592,47],[3,128640,69],[0,128710,5],[3,128716],[0,128717,2],[3,128720,2],[0,128723,1],[3,128725],[0,128736,10],[3,128747,1],[0,128752,3],[3,128756,6],[0,128768,115],[0,128896,88],[3,128992,11],[0,129024,11],[0,129040,55],[0,129104,9],[0,129120,39],[0,129168,29],[0,129280,11],[3,129293,100],[3,129395,3],[3,129402,40],[3,129445,5],[3,129454,28],[3,129485,50],[0,129536,83],[0,129632,13],[3,129648,3],[3,129656,2],[3,129664,2],[3,129680,5],[3,131072,65533],[3,196608,65533],[0,917505],[0,917536,95],[2,917760,239],[2,983040,65533],[2,1048576,65533],]
|
5
|
+
TYPES=[:N,:Na,:A,:W,:H,:F]
|
6
|
+
end
|
7
|
+
end
|
data/lib/unicode/eaw.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "unicode/eaw/version"
|
2
|
+
require "unicode/eaw/data"
|
3
|
+
|
4
|
+
module Unicode
|
5
|
+
module Eaw
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
def width(ch)
|
9
|
+
cp = ch[0].ord
|
10
|
+
left = 0
|
11
|
+
right = DATA.length - 1
|
12
|
+
while left <= right
|
13
|
+
middle = Integer(left + (right - left) / 2);
|
14
|
+
range = DATA[middle]
|
15
|
+
if cp < range[1]
|
16
|
+
right = middle - 1
|
17
|
+
next
|
18
|
+
else
|
19
|
+
end_n = range[1]
|
20
|
+
if range.length == 3
|
21
|
+
end_n = range[1] + range[2]
|
22
|
+
end
|
23
|
+
if cp > end_n
|
24
|
+
left = middle + 1
|
25
|
+
next
|
26
|
+
else
|
27
|
+
type = TYPES[range[0]]
|
28
|
+
if !type
|
29
|
+
raise Error, "Unexpected type: #{range[0]}"
|
30
|
+
end
|
31
|
+
return type
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
return :N
|
36
|
+
end
|
37
|
+
|
38
|
+
module_function :width
|
39
|
+
end
|
40
|
+
end
|
data/tools/generate.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
URL = 'https://www.unicode.org/Public/12.1.0/ucd/EastAsianWidth.txt'
|
4
|
+
TYPES = Hash.new
|
5
|
+
|
6
|
+
def output_line(curr_start, curr_end, curr_type)
|
7
|
+
type_id = TYPES[curr_type] ||= TYPES.keys.length
|
8
|
+
if curr_end
|
9
|
+
diff = curr_end.to_i(16) - curr_start.to_i(16)
|
10
|
+
printf("[%d,%d,%d],", type_id, curr_start.to_i(16), diff)
|
11
|
+
else
|
12
|
+
printf("[%d,%d],", type_id, curr_start.to_i(16))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_header(line)
|
17
|
+
print line.sub(/^# (EastAsianWidth-.*)$/){ "## #{$1}" }
|
18
|
+
print <<~EOB
|
19
|
+
module Unicode
|
20
|
+
module Eaw
|
21
|
+
EOB
|
22
|
+
print " DATA=["
|
23
|
+
end
|
24
|
+
|
25
|
+
content = open(URL).read
|
26
|
+
prev_start = prev_end = prev_type = nil
|
27
|
+
content.each_line.with_index do |line, n|
|
28
|
+
if n == 0
|
29
|
+
output_header(line)
|
30
|
+
elsif line =~ /^([0-9A-Z]+)(?:\.\.([0-9A-Z]+))?;(\w+)/
|
31
|
+
curr_start, curr_end, curr_type = $1, $2, $3
|
32
|
+
if curr_type == prev_type &&
|
33
|
+
((prev_end && prev_end.to_i(16) + 1 == curr_start.to_i(16)) ||
|
34
|
+
(!prev_end && prev_start.to_i(16) + 1 == curr_start.to_i(16)))
|
35
|
+
## concat this line with previous line
|
36
|
+
if curr_end
|
37
|
+
prev_end = curr_end
|
38
|
+
else
|
39
|
+
prev_end = curr_start
|
40
|
+
end
|
41
|
+
else
|
42
|
+
if prev_start
|
43
|
+
## output previous line
|
44
|
+
output_line(prev_start, prev_end, prev_type)
|
45
|
+
end
|
46
|
+
prev_start, prev_end, prev_type = curr_start, curr_end, curr_type
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
## output last line
|
52
|
+
output_line(prev_start, prev_end, prev_type)
|
53
|
+
puts "]"
|
54
|
+
types_str = TYPES.keys.map{|ch| ':'+ch}.join(",")
|
55
|
+
puts ' TYPES=[' + types_str + ']'
|
56
|
+
puts <<~EOB
|
57
|
+
end
|
58
|
+
end
|
59
|
+
EOB
|
60
|
+
|
data/unicode-eaw.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "unicode/eaw/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "unicode-eaw"
|
8
|
+
spec.version = Unicode::Eaw::VERSION
|
9
|
+
spec.authors = ["takahashim"]
|
10
|
+
spec.email = ["maki@rubycolor.org"]
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.summary = %q{Unicode East Asian Width data for Ruby.}
|
14
|
+
spec.description = %q{Unicode East Asian Width data for Ruby.}
|
15
|
+
spec.homepage = "https://github.com/takahashim/unicode-eaw"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unicode-eaw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- takahashim
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Unicode East Asian Width data for Ruby.
|
56
|
+
email:
|
57
|
+
- maki@rubycolor.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/unicode/eaw.rb
|
72
|
+
- lib/unicode/eaw/data.rb
|
73
|
+
- lib/unicode/eaw/version.rb
|
74
|
+
- tools/generate.rb
|
75
|
+
- unicode-eaw.gemspec
|
76
|
+
homepage: https://github.com/takahashim/unicode-eaw
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.0.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Unicode East Asian Width data for Ruby.
|
99
|
+
test_files: []
|