cjk_helper 1.0
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.
- checksums.yaml +7 -0
- data/README.md +1 -0
- data/lib/cjk_helper.rb +54 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 4a73037de7b61a7d55d6d07cb0b5686c1e0715cd
|
|
4
|
+
data.tar.gz: d4eae3dcf6ec5c692294358769d20f4f044171a1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0e26c701c5a0d9ff4fc7f854c131d80bb4a643061311c75c45f679b883912efef436ce4622fd23900b88ce928d7511e3456d8de0e7849a1e600b88ab39e560d9
|
|
7
|
+
data.tar.gz: 51b3d8f6c7a4c0bfd45c92018ba6b1144b619e84f4b4c13cffcf957384b4403432e2ad6e3d86200a7fb65c223298fde258c2a231a14e6e22d38c41cf44e52dff
|
data/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a simple gem to check if a string contains CJK, or a character is CJK
|
data/lib/cjk_helper.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module CJKHelper
|
|
2
|
+
CJKV_RANGES = [
|
|
3
|
+
(0xe2ba80..0xe2bbbf),
|
|
4
|
+
(0xe2bfb0..0xe2bfbf),
|
|
5
|
+
(0xe38080..0xe380bf),
|
|
6
|
+
(0xe38180..0xe383bf),
|
|
7
|
+
(0xe38480..0xe386bf),
|
|
8
|
+
(0xe38780..0xe387bf),
|
|
9
|
+
(0xe38880..0xe38bbf),
|
|
10
|
+
(0xe38c80..0xe38fbf),
|
|
11
|
+
(0xe39080..0xe4b6bf),
|
|
12
|
+
(0xe4b780..0xe4b7bf),
|
|
13
|
+
(0xe4b880..0xe9bfbf),
|
|
14
|
+
(0xea8080..0xea98bf),
|
|
15
|
+
(0xeaa080..0xeaaebf),
|
|
16
|
+
(0xeaaf80..0xefbfbf),
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
def self.is_cjk(char)
|
|
20
|
+
if CJKV_RANGES.any? {|range| range.member? char.unpack('H*').first.hex }
|
|
21
|
+
true
|
|
22
|
+
else
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.all_cjk?(str)
|
|
28
|
+
str.chars.each do |c|
|
|
29
|
+
if !is_cjk(c)
|
|
30
|
+
return false
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.none_cjk?(str)
|
|
37
|
+
str.chars.each do |c|
|
|
38
|
+
if is_cjk(c)
|
|
39
|
+
return false
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.get_cjk(str)
|
|
46
|
+
cjk = ''
|
|
47
|
+
str.chars.each do |c|
|
|
48
|
+
if is_cjk(c)
|
|
49
|
+
cjk += c
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
cjk
|
|
53
|
+
end
|
|
54
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cjk_helper
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '1.0'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Minghe Huang
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: CJK is very annoying
|
|
14
|
+
email: h.mignhe@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- README.md
|
|
20
|
+
- lib/cjk_helper.rb
|
|
21
|
+
homepage: http://minghe.me
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.4.5
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: a simple gem to check if a string contains CJK, or a character is CJK
|
|
45
|
+
test_files: []
|
|
46
|
+
has_rdoc:
|