unicode 0.4.3 → 0.4.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +23 -0
- data/ext/unicode/extconf.rb +3 -0
- data/{unicode.c → ext/unicode/unicode.c} +1 -1
- data/{unidata.map → ext/unicode/unidata.map} +0 -0
- data/{ustring.c → ext/unicode/ustring.c} +0 -0
- data/{ustring.h → ext/unicode/ustring.h} +0 -0
- data/{wstring.c → ext/unicode/wstring.c} +0 -0
- data/{wstring.h → ext/unicode/wstring.h} +0 -0
- data/lib/unicode.rb +6 -0
- data/test/test.rb +69 -0
- data/unicode.gemspec +29 -0
- metadata +15 -11
- data/extconf.rb +0 -3
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rake/clean"
|
2
|
+
require "rake/extensiontask"
|
3
|
+
require "rubygems/package_task"
|
4
|
+
|
5
|
+
CLEAN << "pkg" << "tmp" << "lib/unicode"
|
6
|
+
|
7
|
+
gem_spec = eval(File.read(File.expand_path("../unicode.gemspec", __FILE__)))
|
8
|
+
|
9
|
+
Gem::PackageTask.new(gem_spec) {|pkg|}
|
10
|
+
|
11
|
+
Rake::ExtensionTask.new('unicode_native', gem_spec) do |ext|
|
12
|
+
ext.cross_compile = true
|
13
|
+
ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
|
14
|
+
ext.ext_dir = "ext/unicode"
|
15
|
+
ext.lib_dir = "lib/unicode"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Build native gems for Windows"
|
19
|
+
task :windows_gem => :clean do
|
20
|
+
ENV["RUBY_CC_VERSION"] = "1.8.7:1.9.3"
|
21
|
+
sh "rake cross compile"
|
22
|
+
sh "rake cross native gem"
|
23
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/unicode.rb
ADDED
data/test/test.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#! /usr/local/bin/ruby -KU
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
require 'unicode'
|
5
|
+
|
6
|
+
## dump Unicode string
|
7
|
+
class String
|
8
|
+
def udump
|
9
|
+
ustr = self.unpack("U*")
|
10
|
+
ret = []
|
11
|
+
ustr.each do |e|
|
12
|
+
if e.is_a?(Integer)
|
13
|
+
ret << "U+%04X" % e
|
14
|
+
else
|
15
|
+
ret << e
|
16
|
+
end
|
17
|
+
end
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
print "Canonical decomposition vs compatibility decomposition\n"
|
24
|
+
p Unicode::decompose("⑽ o\xef\xac\x83ce").udump
|
25
|
+
p Unicode::decompose_compat("⑽ o\xef\xac\x83ce")
|
26
|
+
|
27
|
+
print "Canonical equivalent vs Compatibility equivalent\n"
|
28
|
+
p Unicode::strcmp("ガ", "ガ")
|
29
|
+
p Unicode::strcmp("ガ", "ガ")
|
30
|
+
p Unicode::strcmp_compat("ガ", "ガ")
|
31
|
+
|
32
|
+
print "Decomposition/composition\n"
|
33
|
+
p Unicode::normalize_D([0x63, 0x301, 0x327].pack("U*")).udump
|
34
|
+
p Unicode::normalize_D([0x63, 0x327, 0x301].pack("U*")).udump
|
35
|
+
p Unicode::normalize_D([0x107, 0x327].pack("U*")).udump
|
36
|
+
p Unicode::normalize_D([0xe7, 0x301].pack("U*")).udump
|
37
|
+
p Unicode::normalize_C([0x63, 0x301, 0x327].pack("U*")).udump
|
38
|
+
p Unicode::normalize_C([0x63, 0x327, 0x301].pack("U*")).udump
|
39
|
+
p Unicode::normalize_C([0x107, 0x327].pack("U*")).udump
|
40
|
+
p Unicode::normalize_C([0xe7, 0x301].pack("U*")).udump
|
41
|
+
|
42
|
+
print "Kana Normalization\n"
|
43
|
+
p Unicode::normalize_D("ガガ").udump
|
44
|
+
p Unicode::normalize_C("ガガ").udump
|
45
|
+
p Unicode::normalize_KD("ガガ").udump
|
46
|
+
p Unicode::normalize_KC("ガガ").udump
|
47
|
+
|
48
|
+
print "Hangul\n"
|
49
|
+
p "요시담".udump
|
50
|
+
p Unicode::normalize_D("요시담").udump
|
51
|
+
p Unicode::normalize_C("요시담").udump
|
52
|
+
|
53
|
+
print "Composition Exclusion\n"
|
54
|
+
print " ANGSTROM SIGN [U+212B]\n"
|
55
|
+
p Unicode::normalize_D([0x212b].pack("U")).udump
|
56
|
+
p Unicode::normalize_C([0x212b].pack("U")).udump
|
57
|
+
print " LATIN CAPITAL LETTER A WITH RING ABOVE [U+00C5]\n"
|
58
|
+
p Unicode::normalize_D([0x00c5].pack("U")).udump
|
59
|
+
p Unicode::normalize_C([0x00c5].pack("U")).udump
|
60
|
+
|
61
|
+
print "Case conversion\n"
|
62
|
+
p Unicode::normalize_C(Unicode::upcase([0x63, 0x301, 0x327, 0xff41].pack("U*"))).udump
|
63
|
+
p Unicode::normalize_C(Unicode::downcase([0x43, 0x301, 0x327, 0xff21].pack("U*"))).udump
|
64
|
+
p Unicode::capitalize([0x1f1, 0x41, 0x61, 0xff21].pack("U*")).udump
|
65
|
+
|
66
|
+
|
67
|
+
## Local variables:
|
68
|
+
## coding: utf-8
|
69
|
+
## End:
|
data/unicode.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{unicode}
|
5
|
+
s.version = "0.4.3.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = [%q{Yoshida Masato}]
|
9
|
+
s.date = %q{2012-08-07}
|
10
|
+
s.email = %q{yoshidam@yoshidam.net}
|
11
|
+
s.extensions = %w[ext/unicode/extconf.rb]
|
12
|
+
s.extra_rdoc_files = %w[README]
|
13
|
+
s.files = %w[
|
14
|
+
README Rakefile unicode.gemspec lib/unicode.rb
|
15
|
+
test/test.rb tools/README tools/mkunidata.rb tools/normtest.rb
|
16
|
+
ext/unicode/extconf.rb ext/unicode/unicode.c ext/unicode/unidata.map
|
17
|
+
ext/unicode/ustring.c ext/unicode/ustring.h ext/unicode/wstring.c ext/unicode/wstring.h
|
18
|
+
]
|
19
|
+
s.homepage = %q{http://www.yoshidam.net/Ruby.html#unicode}
|
20
|
+
s.require_paths = %w[lib]
|
21
|
+
s.rubygems_version = %q{1.8.6}
|
22
|
+
s.summary = %q{Unicode normalization library.}
|
23
|
+
s.description = %q{Unicode normalization library.}
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
s.specification_version = 3
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.3
|
4
|
+
version: 0.4.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,27 +15,31 @@ description: Unicode normalization library.
|
|
15
15
|
email: yoshidam@yoshidam.net
|
16
16
|
executables: []
|
17
17
|
extensions:
|
18
|
-
- extconf.rb
|
18
|
+
- ext/unicode/extconf.rb
|
19
19
|
extra_rdoc_files:
|
20
20
|
- README
|
21
21
|
files:
|
22
|
-
- extconf.rb
|
23
|
-
- unicode.c
|
24
|
-
- ustring.c
|
25
|
-
- ustring.h
|
26
|
-
- wstring.c
|
27
|
-
- wstring.h
|
28
22
|
- README
|
23
|
+
- Rakefile
|
24
|
+
- unicode.gemspec
|
25
|
+
- lib/unicode.rb
|
26
|
+
- test/test.rb
|
27
|
+
- tools/README
|
29
28
|
- tools/mkunidata.rb
|
30
29
|
- tools/normtest.rb
|
31
|
-
-
|
32
|
-
-
|
30
|
+
- ext/unicode/extconf.rb
|
31
|
+
- ext/unicode/unicode.c
|
32
|
+
- ext/unicode/unidata.map
|
33
|
+
- ext/unicode/ustring.c
|
34
|
+
- ext/unicode/ustring.h
|
35
|
+
- ext/unicode/wstring.c
|
36
|
+
- ext/unicode/wstring.h
|
33
37
|
homepage: http://www.yoshidam.net/Ruby.html#unicode
|
34
38
|
licenses: []
|
35
39
|
post_install_message:
|
36
40
|
rdoc_options: []
|
37
41
|
require_paths:
|
38
|
-
-
|
42
|
+
- lib
|
39
43
|
required_ruby_version: !ruby/object:Gem::Requirement
|
40
44
|
none: false
|
41
45
|
requirements:
|
data/extconf.rb
DELETED