string-width-tanasinn 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.html +389 -0
- data/LICENSE.txt +470 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/lib/string-width/tanasinn/regexp.rb +112 -0
- data/lib/string-width/tanasinn/version.rb +5 -0
- data/lib/string-width/tanasinn/wcwidth.rb +90 -0
- data/lib/string-width/tanasinn.rb +8 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/wcwidth_spec.rb +66 -0
- data/string-width-tanasinn.gemspec +19 -0
- data/wcwidth.js +106 -0
- metadata +65 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
***** BEGIN LICENSE BLOCK *****
|
|
5
|
+
Version: MPL 1.1
|
|
6
|
+
|
|
7
|
+
The contents of this file are subject to the Mozilla Public License Version
|
|
8
|
+
1.1 (the "License"); you may not use this file except in compliance with
|
|
9
|
+
the License. You may obtain a copy of the License at
|
|
10
|
+
http://www.mozilla.org/MPL/
|
|
11
|
+
|
|
12
|
+
Software distributed under the License is distributed on an "AS IS" basis,
|
|
13
|
+
|
|
14
|
+
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
15
|
+
for the specific language governing rights and limitations under the
|
|
16
|
+
License.
|
|
17
|
+
|
|
18
|
+
The Original Code is tanasinn
|
|
19
|
+
|
|
20
|
+
The Initial Developer of the Original Code is * Hayaki Saito.
|
|
21
|
+
Portions created by the Initial Developer are Copyright (C) 2010 - 2011
|
|
22
|
+
the Initial Developer. All Rights Reserved.
|
|
23
|
+
|
|
24
|
+
***** END LICENSE BLOCK *****
|
|
25
|
+
=end
|
|
26
|
+
|
|
27
|
+
require 'string-width/tanasinn/regexp'
|
|
28
|
+
|
|
29
|
+
module StringWidth
|
|
30
|
+
module Tanasinn
|
|
31
|
+
def self.wcwidth_amb_as_single(s)
|
|
32
|
+
raise ArgumentError unless s.size == 1
|
|
33
|
+
c = s.ord
|
|
34
|
+
case
|
|
35
|
+
when c < 0x10000
|
|
36
|
+
case s
|
|
37
|
+
when RE_AMB_AS_SINGLE_2
|
|
38
|
+
2
|
|
39
|
+
when RE_WIDTH_0_CHARS
|
|
40
|
+
0
|
|
41
|
+
end
|
|
42
|
+
when c < 0x1F100
|
|
43
|
+
1
|
|
44
|
+
when c < 0x1F300
|
|
45
|
+
case
|
|
46
|
+
when ARY_AMB_AS_SINGLE_1.include?(c)
|
|
47
|
+
1
|
|
48
|
+
else
|
|
49
|
+
2
|
|
50
|
+
end
|
|
51
|
+
when c < 0x20000
|
|
52
|
+
1
|
|
53
|
+
when c < 0xE0000
|
|
54
|
+
2
|
|
55
|
+
when c < 0xE1000
|
|
56
|
+
1
|
|
57
|
+
when c > 0xFFFFF
|
|
58
|
+
1
|
|
59
|
+
else
|
|
60
|
+
raise RangeError "codepoint out of range"
|
|
61
|
+
end or 1
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.wcwidth_amb_as_double(s)
|
|
65
|
+
raise ArgumentError unless s.size == 1
|
|
66
|
+
c = s.ord
|
|
67
|
+
case
|
|
68
|
+
when c < 0x10000
|
|
69
|
+
case s
|
|
70
|
+
when RE_AMB_AS_DOUBLE_2
|
|
71
|
+
2
|
|
72
|
+
when RE_WIDTH_0_CHARS
|
|
73
|
+
0
|
|
74
|
+
end
|
|
75
|
+
when c < 0x1F100
|
|
76
|
+
1
|
|
77
|
+
when c < 0x1F200
|
|
78
|
+
2
|
|
79
|
+
when c < 0x1F300
|
|
80
|
+
2
|
|
81
|
+
when c < 0x20000
|
|
82
|
+
2
|
|
83
|
+
when c > 0xFFFFF
|
|
84
|
+
2
|
|
85
|
+
else
|
|
86
|
+
raise RangeError "codepoint out of range"
|
|
87
|
+
end or 1
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
|
|
6
|
+
describe StringWidth::Tanasinn do
|
|
7
|
+
before(:all){ include StringWidth::Tanasinn }
|
|
8
|
+
describe "As single" do
|
|
9
|
+
context "Ascii" do
|
|
10
|
+
it "large A" do
|
|
11
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("A").should == 1
|
|
12
|
+
end
|
|
13
|
+
it "large Z" do
|
|
14
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("Z").should == 1
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
context "Japanese" do
|
|
18
|
+
it "Hiragana NU" do
|
|
19
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("ぬ").should == 2
|
|
20
|
+
end
|
|
21
|
+
it "Hiragana RU" do
|
|
22
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("る").should == 2
|
|
23
|
+
end
|
|
24
|
+
it "Hiragana PO" do
|
|
25
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("ぽ").should == 2
|
|
26
|
+
end
|
|
27
|
+
it "Half Katakana GA" do
|
|
28
|
+
->{
|
|
29
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("ガ")
|
|
30
|
+
}.should raise_error ArgumentError
|
|
31
|
+
end
|
|
32
|
+
it "Half Katakana Small TSU" do
|
|
33
|
+
StringWidth::Tanasinn::wcwidth_amb_as_single("ッ").should == 1
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
describe "As double" do
|
|
38
|
+
context "Ascii" do
|
|
39
|
+
it "large A" do
|
|
40
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("A").should == 1
|
|
41
|
+
end
|
|
42
|
+
it "large Z" do
|
|
43
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("Z").should == 1
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
context "Japanese" do
|
|
47
|
+
it "Hiragana NU" do
|
|
48
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("ぬ").should == 2
|
|
49
|
+
end
|
|
50
|
+
it "Hiragana RU" do
|
|
51
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("る").should == 2
|
|
52
|
+
end
|
|
53
|
+
it "Hiragana PO" do
|
|
54
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("ぽ").should == 2
|
|
55
|
+
end
|
|
56
|
+
it "Half Katakana GA" do
|
|
57
|
+
->{
|
|
58
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("ガ")
|
|
59
|
+
}.should raise_error ArgumentError
|
|
60
|
+
end
|
|
61
|
+
it "Half Katakana Small TSU" do
|
|
62
|
+
StringWidth::Tanasinn::wcwidth_amb_as_double("ッ").should == 1
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'string-width/tanasinn/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "string-width-tanasinn"
|
|
8
|
+
gem.version = StringWidth::Tanasinn::VERSION
|
|
9
|
+
gem.authors = ["USAMI Kenta"]
|
|
10
|
+
gem.email = ["tadsan@zonu.me"]
|
|
11
|
+
gem.description = %q{this gem provide module function that imported the algorithm to measure the width of the Charactor from `tanasinn' terminal emulator. The function is divided into the thing except thing and it for CJK environment.}
|
|
12
|
+
gem.summary = "imported the algorithm to measure the width of the Charactor from `tanasinn' terminal emulator."
|
|
13
|
+
gem.homepage = "https://github.com/zonuexe/string-width-tanasinn"
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ["lib"]
|
|
19
|
+
end
|
data/wcwidth.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* -*- Mode: JAVASCRIPT; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
2
|
+
*
|
|
3
|
+
* ***** BEGIN LICENSE BLOCK *****
|
|
4
|
+
* Version: MPL 1.1
|
|
5
|
+
*
|
|
6
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
|
7
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
8
|
+
* the License. You may obtain a copy of the License at
|
|
9
|
+
* http://www.mozilla.org/MPL/
|
|
10
|
+
*
|
|
11
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
13
|
+
* for the specific language governing rights and limitations under the
|
|
14
|
+
* License.
|
|
15
|
+
*
|
|
16
|
+
* The Original Code is tanasinn
|
|
17
|
+
*
|
|
18
|
+
* The Initial Developer of the Original Code is * Hayaki Saito.
|
|
19
|
+
* Portions created by the Initial Developer are Copyright (C) 2010 - 2011
|
|
20
|
+
* the Initial Developer. All Rights Reserved.
|
|
21
|
+
*
|
|
22
|
+
* ***** END LICENSE BLOCK ***** */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function wcwidth_amb_as_single(c)
|
|
26
|
+
{
|
|
27
|
+
if (c < 0x10000) {
|
|
28
|
+
var s = String.fromCharCode(c);
|
|
29
|
+
if (/[\u1100-\u115f\u11a3-\u11a7\u11fa-\u11ff\u2329\u232a\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u2ffb\u3000-\u3029\u302e-\u303e\u3041-\u3096\u309b-\u30ff\u3105-\u312d\u3131-\u318e\u3190-\u31ba\u31c0-\u31e3\u31f0-\u321e\u3220-\u3247\u3250-\u32fe\u3300-\u4dbf\u4e00-\ua48c\ua490-\ua4c6\ua960-\ua97c\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe66\ufe68-\ufe6b\uff01-\uff60\uffe0-\uffe6\uac00-\ud7a3\ufa6e\ufa6f\ufada]/.test(s)) {
|
|
30
|
+
return 2;
|
|
31
|
+
} else if (/[\u00ad\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0600-\u0604\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dd\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u070f\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962\u0963\u0981\u09bc\u09c1-\u09c4\u09cd\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b62\u0b63\u0b82\u0bc0\u0bcd\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc6\u0ccc\u0ccd\u0ce2\u0ce3\u0d41-\u0d44\u0d4d\u0d62\u0d63\u0dca\u0dd2-\u0dd4\u0dd6\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1bab\u1be6\u1be8\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200b-\u200f\u202a-\u202e\u2060-\u2064\u206a-\u206f\u20d0-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u3099\u309a\ua66f-\ua672\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaec\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufeff\ufff9]/.test(s)) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
} else if (c < 0x1F100) {
|
|
35
|
+
return 1;
|
|
36
|
+
} else if (c < 0x1F300) {
|
|
37
|
+
switch (c) {
|
|
38
|
+
case 0x1F12E:
|
|
39
|
+
case 0x1F16A:
|
|
40
|
+
case 0x1F16B:
|
|
41
|
+
case 0x1F1E6:
|
|
42
|
+
case 0x1F1E7:
|
|
43
|
+
case 0x1F1E8:
|
|
44
|
+
case 0x1F1E9:
|
|
45
|
+
case 0x1F1EA:
|
|
46
|
+
case 0x1F1EB:
|
|
47
|
+
case 0x1F1EC:
|
|
48
|
+
case 0x1F1ED:
|
|
49
|
+
case 0x1F1EE:
|
|
50
|
+
case 0x1F1EF:
|
|
51
|
+
case 0x1F1F0:
|
|
52
|
+
case 0x1F1F1:
|
|
53
|
+
case 0x1F1F2:
|
|
54
|
+
case 0x1F1F3:
|
|
55
|
+
case 0x1F1F4:
|
|
56
|
+
case 0x1F1F5:
|
|
57
|
+
case 0x1F1F6:
|
|
58
|
+
case 0x1F1F7:
|
|
59
|
+
case 0x1F1F8:
|
|
60
|
+
case 0x1F1F9:
|
|
61
|
+
case 0x1F1FA:
|
|
62
|
+
case 0x1F1FB:
|
|
63
|
+
case 0x1F1FC:
|
|
64
|
+
case 0x1F1FD:
|
|
65
|
+
case 0x1F1FE:
|
|
66
|
+
case 0x1F1FF:
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
return 2;
|
|
70
|
+
} else if (c < 0x20000) {
|
|
71
|
+
return 1;
|
|
72
|
+
} else if (c < 0xE0000) {
|
|
73
|
+
return 2;
|
|
74
|
+
} else if (c < 0xE1000) {
|
|
75
|
+
return 1;
|
|
76
|
+
} else if (c > 0xFFFFF) {
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function wcwidth_amb_as_double(c)
|
|
83
|
+
{
|
|
84
|
+
if (c < 0x10000) {
|
|
85
|
+
var s = String.fromCharCode(c);
|
|
86
|
+
if (/[\u00a1\u00a4\u00a7\u00a8\u00aa\u00ae\u00b0-\u00b4\u00b6-\u00ba\u00bc-\u00bf\u00c6\u00d0\u00d7\u00d8\u00de-\u00e1\u00e6\u00e8-\u00ea\u00ec\u00ed\u00f0\u00f2\u00f3\u00f7-\u00fa\u00fc\u00fe\u0101\u0111\u0113\u011b\u0126\u0127\u012b\u0131-\u0133\u0138\u013f-\u0142\u0144\u0148-\u014b\u014d\u0152\u0153\u0166\u0167\u016b\u01ce\u01d0\u01d2\u01d4\u01d6\u01d8\u01da\u01dc\u0251\u0261\u02c4\u02c7\u02c9-\u02cb\u02cd\u02d0\u02d8-\u02db\u02dd\u02df\u0391-\u03a1\u03a3-\u03a9\u03b1-\u03c1\u03c3-\u03c9\u0401\u0410-\u044f\u0451\u1100-\u115f\u11a3-\u11a7\u11fa-\u11ff\u2010\u2013-\u2016\u2018\u2019\u201c\u201d\u2020-\u2022\u2024-\u2027\u2030\u2032\u2033\u2035\u203b\u203e\u2074\u207f\u2081-\u2084\u20ac\u2103\u2105\u2109\u2113\u2116\u2121\u2122\u2126\u212b\u2153\u2154\u215b-\u215e\u2160-\u216b\u2170-\u2179\u2189\u2190-\u2199\u21b8\u21b9\u21d2\u21d4\u21e7\u2200\u2202\u2203\u2207\u2208\u220b\u220f\u2211\u2215\u221a\u221d-\u2220\u2223\u2225\u2227-\u222c\u222e\u2234-\u2237\u223c\u223d\u2248\u224c\u2252\u2260\u2261\u2264-\u2267\u226a\u226b\u226e\u226f\u2282\u2283\u2286\u2287\u2295\u2299\u22a5\u22bf\u2312\u2329\u232a\u2460-\u24e9\u24eb-\u254b\u2550-\u2573\u2580-\u258f\u2592-\u2595\u25a0\u25a1\u25a3-\u25a9\u25b2\u25b3\u25b6\u25b7\u25bc\u25bd\u25c0\u25c1\u25c6-\u25c8\u25cb\u25ce-\u25d1\u25e2-\u25e5\u25ef\u2605\u2606\u2609\u260e\u260f\u2614\u2615\u261c\u261e\u2640\u2642\u2660\u2661\u2663-\u2665\u2667-\u266a\u266c\u266d\u266f\u269e\u269f\u26be\u26bf\u26c4-\u26cd\u26cf-\u26e1\u26e3\u26e8-\u26ff\u273d\u2757\u2776-\u277f\u2b55-\u2b59\u2e80-\u2e99\u2e9b-\u2ef3\u2f00-\u2fd5\u2ff0-\u2ffb\u3000-\u3029\u302e-\u303e\u3041-\u3096\u309b-\u30ff\u3105-\u312d\u3131-\u318e\u3190-\u31ba\u31c0-\u31e3\u31f0-\u321e\u3220-\u32fe\u3300-\u4dbf\u4e00-\ua48c\ua490-\ua4c6\ua960-\ua97c\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe66\ufe68-\ufe6b\uff01-\uff60\uffe0-\uffe6\ufffd\uac00-\ud7a3\ue000-\uf8ff\ufa6e\ufa6f\ufada]/.test(s)) {
|
|
87
|
+
return 2;
|
|
88
|
+
} else if (/[\u00ad\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0600-\u0604\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dd\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u070f\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e4-\u08fe\u0900-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962\u0963\u0981\u09bc\u09c1-\u09c4\u09cd\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b62\u0b63\u0b82\u0bc0\u0bcd\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc6\u0ccc\u0ccd\u0ce2\u0ce3\u0d41-\u0d44\u0d4d\u0d62\u0d63\u0dca\u0dd2-\u0dd4\u0dd6\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1bab\u1be6\u1be8\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1dc0-\u1de6\u1dfc-\u1dff\u200b-\u200f\u202a-\u202e\u2060-\u2064\u206a-\u206f\u20d0-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u3099\u309a\ua66f-\ua672\ua674-\ua67d\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaec\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\ufeff\ufff9]/.test(s)) {
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
} else if (c < 0x1F200) {
|
|
92
|
+
return 1;
|
|
93
|
+
} else if (c < 0x1F200) {
|
|
94
|
+
return 2;
|
|
95
|
+
} else if (c < 0x1F300) {
|
|
96
|
+
return 2;
|
|
97
|
+
} else if (c < 0x20000) {
|
|
98
|
+
return 1;
|
|
99
|
+
} else if (c < 0xE0000) {
|
|
100
|
+
return 2;
|
|
101
|
+
} else if (c > 0xFFFFF) {
|
|
102
|
+
return 2;
|
|
103
|
+
}
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: string-width-tanasinn
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- USAMI Kenta
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-10-20 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: this gem provide module function that imported the algorithm to measure
|
|
15
|
+
the width of the Charactor from `tanasinn' terminal emulator. The function is divided
|
|
16
|
+
into the thing except thing and it for CJK environment.
|
|
17
|
+
email:
|
|
18
|
+
- tadsan@zonu.me
|
|
19
|
+
executables: []
|
|
20
|
+
extensions: []
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- .gitignore
|
|
24
|
+
- Gemfile
|
|
25
|
+
- LICENSE.html
|
|
26
|
+
- LICENSE.txt
|
|
27
|
+
- README.md
|
|
28
|
+
- Rakefile
|
|
29
|
+
- lib/string-width/tanasinn.rb
|
|
30
|
+
- lib/string-width/tanasinn/regexp.rb
|
|
31
|
+
- lib/string-width/tanasinn/version.rb
|
|
32
|
+
- lib/string-width/tanasinn/wcwidth.rb
|
|
33
|
+
- spec/spec_helper.rb
|
|
34
|
+
- spec/wcwidth_spec.rb
|
|
35
|
+
- string-width-tanasinn.gemspec
|
|
36
|
+
- wcwidth.js
|
|
37
|
+
homepage: https://github.com/zonuexe/string-width-tanasinn
|
|
38
|
+
licenses: []
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
45
|
+
requirements:
|
|
46
|
+
- - ! '>='
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubyforge_project:
|
|
57
|
+
rubygems_version: 1.8.24
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 3
|
|
60
|
+
summary: imported the algorithm to measure the width of the Charactor from `tanasinn'
|
|
61
|
+
terminal emulator.
|
|
62
|
+
test_files:
|
|
63
|
+
- spec/spec_helper.rb
|
|
64
|
+
- spec/wcwidth_spec.rb
|
|
65
|
+
has_rdoc:
|