ansel_iconv 1.1.5 → 1.1.7
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/CHANGELOG.md +9 -0
- data/{MIT-LICENSE → LICENSE} +1 -1
- data/README.md +18 -11
- data/ansel_iconv.gemspec +25 -0
- data/lib/ansel_iconv/character_map.rb +2 -0
- data/lib/ansel_iconv/converter.rb +18 -16
- data/lib/ansel_iconv/iconv.rb +5 -3
- data/lib/ansel_iconv/version.rb +5 -1
- data/lib/ansel_iconv.rb +0 -2
- metadata +56 -77
- data/Rakefile +0 -45
- data/test/ansel_iconv_test.rb +0 -103
- data/test/test_helper.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d593449dba631156ac82a8f1581ea9c769578fd8f74c3c9192157f03625465a4
|
4
|
+
data.tar.gz: fbaa3bb8e75684b9539d6140f634d1013bfbda5320c85b8b0bd0105015fedded
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 034c69a1ba0621b2b0c4da10796d5b80d9c25582d0a03d2366ebf52848e099231663371a9ea1662477b8bb1c64c2a3b3a854f19422a0cafa6a2765641a6df5e3
|
7
|
+
data.tar.gz: 617a594283bf4e8bfc706f0bf8166823372b9ceeba2c3038a286425d20d351ae204ed82dff8c0c9536136a0b69229b817910b7d70e71b38782cc97742b178244
|
data/CHANGELOG.md
CHANGED
data/{MIT-LICENSE → LICENSE}
RENAMED
data/README.md
CHANGED
@@ -1,42 +1,49 @@
|
|
1
1
|
# ANSEL::Iconv
|
2
2
|
|
3
|
+
[](https://rubygems.org/gems/ansel_iconv)
|
4
|
+
[](https://github.com/infused/ansel_iconv)
|
5
|
+
|
6
|
+
|
3
7
|
ANSEL::Iconv is a wrapper for Iconv that adds ANSEL character set conversion.
|
4
8
|
|
5
|
-
Copyright (c) 2006-
|
9
|
+
Copyright (c) 2006-2015 Keith Morrison <mailto:keithm@infused.org>, <http://www.infused.org>
|
6
10
|
|
7
11
|
- Project page: <http://github.com/infused/ansel_iconv>
|
8
|
-
- API Documentation: <http://
|
12
|
+
- API Documentation: <http://rubydoc.info/github/infused/ansel_iconv>
|
9
13
|
- Report bugs: <http://github.com/infused/ansel_iconv/issues>
|
10
14
|
- Questions? Email [keithm@infused.org](mailto:keithm@infused.org?subject=ANSEL::Iconv)
|
11
15
|
with ANSEL::Iconv in the subject line
|
12
|
-
|
16
|
+
|
13
17
|
## Compatibility
|
14
18
|
|
15
|
-
ANSEL::Iconv is compatible with Ruby 1.8.6
|
19
|
+
ANSEL::Iconv is compatible with Ruby 1.8.6 and 1.8.7. Ruby must
|
20
|
+
be compiled with iconv support.
|
21
|
+
|
22
|
+
For ANSEL conversion under Ruby 1.9 and higher see my [ANSEL](https://github.com/infused/ansel) gem.
|
16
23
|
|
17
24
|
## Installation
|
18
25
|
|
19
26
|
gem install ansel_iconv
|
20
|
-
|
27
|
+
|
21
28
|
## Basic Usage
|
22
29
|
|
23
|
-
Conversion from ANSEL to any other encoding is fully supported, but you cannot
|
30
|
+
Conversion from ANSEL to any other encoding is fully supported, but you cannot
|
24
31
|
convert to ANSEL from another encoding. Two-way encoding may be added
|
25
32
|
in the future.
|
26
|
-
|
33
|
+
|
27
34
|
require 'ansel_iconv'
|
28
|
-
|
35
|
+
|
29
36
|
# convert ANSEL to UTF-8
|
30
37
|
converter = ANSEL::Iconv.new 'UTF-8'
|
31
38
|
converter.iconv("\xB9\x004.59") # => "£4.59"
|
32
|
-
|
39
|
+
|
33
40
|
You can use ANSEL::Iconv as a replacement for the built-in Iconv, because
|
34
41
|
non-ANSEL conversions are simply passed through to Iconv.
|
35
42
|
|
36
43
|
# convert UTF-8 to UTF-16
|
37
44
|
converter = ANSEL::Iconv.new 'UTF-16', 'UTF-8'
|
38
45
|
converter.iconv("£4.59") # => "\376\377\000\243\0004\000.\0005\0009"
|
39
|
-
|
46
|
+
|
40
47
|
## About the ANSEL character set
|
41
48
|
|
42
49
|
[ANSI/NISO
|
@@ -49,7 +56,7 @@ standard.
|
|
49
56
|
|
50
57
|
## LICENSE:
|
51
58
|
|
52
|
-
Copyright (c) 2006-
|
59
|
+
Copyright (c) 2006-2015 Keith Morrison <keithm@infused.org>
|
53
60
|
|
54
61
|
Permission is hereby granted, free of charge, to any person obtaining
|
55
62
|
a copy of this software and associated documentation files (the
|
data/ansel_iconv.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib/', __FILE__)
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
5
|
+
require 'ansel_iconv/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'ansel_iconv'
|
9
|
+
s.version = ANSEL::Iconv::VERSION
|
10
|
+
s.authors = ["Keith Morrison"]
|
11
|
+
s.email = 'keithm@infused.org'
|
12
|
+
s.homepage = 'http://github.com/infused/ansel_iconv'
|
13
|
+
s.summary = 'Convert ANSEL encoded text'
|
14
|
+
s.description = 'Convert ANSEL encoded text to any other encoding available to Iconv'
|
15
|
+
|
16
|
+
s.rdoc_options = ['--charset=UTF-8']
|
17
|
+
s.extra_rdoc_files = ['README.md', 'CHANGELOG.md', 'LICENSE']
|
18
|
+
s.files = Dir['README.md', 'CHANGELOG.md', 'LICENSE', 'lib/**/*', 'ansel_iconv.gemspec']
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.required_rubygems_version = '>= 1.3.6'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.10.0'
|
23
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
24
|
+
end
|
25
|
+
|
@@ -3,12 +3,13 @@
|
|
3
3
|
module ANSEL
|
4
4
|
class Convert
|
5
5
|
include ANSEL::CharacterMap
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(to_charset = 'UTF-8')
|
8
8
|
@to_charset = to_charset
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
end
|
10
|
+
|
11
|
+
def ansi_to_utf8
|
12
|
+
@ansi_to_utf8 ||= @@non_combining.merge(@@combining)
|
12
13
|
end
|
13
14
|
|
14
15
|
def iconv(string)
|
@@ -17,32 +18,33 @@ module ANSEL
|
|
17
18
|
until scanner.eos? do
|
18
19
|
byte = scanner.get_byte
|
19
20
|
char = byte.unpack('C')[0]
|
20
|
-
|
21
|
-
|
21
|
+
|
22
|
+
case char
|
23
|
+
when 0x00..0x7F
|
22
24
|
output << byte
|
23
|
-
|
25
|
+
when 0x88..0xC8
|
24
26
|
hex_key = char.to_s(16).upcase
|
25
|
-
output << ::Iconv.conv(@to_charset, 'UTF-
|
27
|
+
output << ::Iconv.conv(@to_charset, 'UTF-16BE', ansi_to_utf8[hex_key] || ansi_to_utf8['ERR'])
|
26
28
|
scanner.get_byte # ignore the next byte
|
27
|
-
|
29
|
+
when 0xE0..0xFB
|
28
30
|
[2, 1, 0].each do |n| # try 3 bytes, then 2 bytes, then 1 byte
|
29
31
|
bytes = [char.to_s(16).upcase]
|
30
32
|
scanner.peek(n).each_byte {|b| bytes << b.to_s(16).upcase}
|
31
|
-
hex_key = bytes.join(
|
32
|
-
if
|
33
|
-
output << ::Iconv.conv(@to_charset, 'UTF-
|
33
|
+
hex_key = bytes.join('+')
|
34
|
+
if ansi_to_utf8.has_key?(hex_key)
|
35
|
+
output << ::Iconv.conv(@to_charset, 'UTF-16BE', ansi_to_utf8[hex_key])
|
34
36
|
n.times {scanner.get_byte}
|
35
37
|
break
|
36
38
|
end
|
37
39
|
end
|
38
40
|
else
|
39
|
-
output << ::Iconv.conv(@to_charset, 'UTF-
|
41
|
+
output << ::Iconv.conv(@to_charset, 'UTF-16BE', ansi_to_utf8['ERR'])
|
40
42
|
scanner.get_byte if scanner.get_byte.unpack('C')[0] >= 0xE0 # ignore the next byte
|
41
43
|
end
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
@to_charset == 'UTF-8' ? output : ::Iconv.conv(@to_charset, 'UTF-8', output)
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
end
|
48
|
-
end
|
50
|
+
end
|
data/lib/ansel_iconv/iconv.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
|
3
3
|
module ANSEL
|
4
|
-
class Iconv
|
5
|
-
delegate :iconv, :to => :@converter
|
6
|
-
|
4
|
+
class Iconv
|
7
5
|
def initialize(to, from = 'ANSEL')
|
8
6
|
@converter = (from == 'ANSEL') ? Convert.new(to) : ::Iconv.new(to, from)
|
9
7
|
end
|
8
|
+
|
9
|
+
def iconv(*args)
|
10
|
+
@converter.iconv(*args)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/ansel_iconv/version.rb
CHANGED
data/lib/ansel_iconv.rb
CHANGED
metadata
CHANGED
@@ -1,103 +1,82 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ansel_iconv
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 5
|
10
|
-
version: 1.1.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.7
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Keith Morrison
|
14
|
-
autorequire:
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.10.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.10.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: 0.9.2
|
34
|
+
type: :development
|
23
35
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
- 5
|
34
|
-
version: 2.3.5
|
35
|
-
- - <=
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
hash: 19
|
38
|
-
segments:
|
39
|
-
- 2
|
40
|
-
- 3
|
41
|
-
- 8
|
42
|
-
version: 2.3.8
|
43
|
-
type: :runtime
|
44
|
-
version_requirements: *id001
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.9.2
|
45
41
|
description: Convert ANSEL encoded text to any other encoding available to Iconv
|
46
42
|
email: keithm@infused.org
|
47
43
|
executables: []
|
48
|
-
|
49
44
|
extensions: []
|
50
|
-
|
51
|
-
extra_rdoc_files:
|
45
|
+
extra_rdoc_files:
|
52
46
|
- README.md
|
53
47
|
- CHANGELOG.md
|
54
|
-
|
48
|
+
- LICENSE
|
49
|
+
files:
|
55
50
|
- CHANGELOG.md
|
56
|
-
-
|
57
|
-
- Rakefile
|
51
|
+
- LICENSE
|
58
52
|
- README.md
|
53
|
+
- ansel_iconv.gemspec
|
54
|
+
- lib/ansel_iconv.rb
|
59
55
|
- lib/ansel_iconv/character_map.rb
|
60
56
|
- lib/ansel_iconv/converter.rb
|
61
57
|
- lib/ansel_iconv/iconv.rb
|
62
58
|
- lib/ansel_iconv/version.rb
|
63
|
-
- lib/ansel_iconv.rb
|
64
|
-
- test/ansel_iconv_test.rb
|
65
|
-
- test/test_helper.rb
|
66
|
-
has_rdoc: true
|
67
59
|
homepage: http://github.com/infused/ansel_iconv
|
68
60
|
licenses: []
|
69
|
-
|
70
|
-
post_install_message:
|
71
|
-
rdoc_options:
|
72
|
-
- --charset=UTF-8
|
73
|
-
require_paths:
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- "--charset=UTF-8"
|
65
|
+
require_paths:
|
74
66
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
|
77
|
-
requirements:
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
78
69
|
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
version: "0"
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
87
74
|
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 1
|
92
|
-
- 3
|
93
|
-
- 0
|
94
|
-
version: 1.3.0
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.3.6
|
95
77
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
signing_key:
|
100
|
-
specification_version: 3
|
78
|
+
rubygems_version: 3.4.13
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
101
81
|
summary: Convert ANSEL encoded text
|
102
82
|
test_files: []
|
103
|
-
|
data/Rakefile
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rubygems/specification'
|
5
|
-
require 'rake/testtask'
|
6
|
-
|
7
|
-
|
8
|
-
desc 'Default: run unit tests.'
|
9
|
-
task :default => :test
|
10
|
-
|
11
|
-
Rake::TestTask.new(:test) do |t|
|
12
|
-
t.pattern = 'test/**/*_test.rb'
|
13
|
-
t.verbose = true
|
14
|
-
t.libs << 'test'
|
15
|
-
end
|
16
|
-
|
17
|
-
def gemspec
|
18
|
-
@gemspec ||= begin
|
19
|
-
file = File.expand_path('../ansel_iconv.gemspec', __FILE__)
|
20
|
-
eval(File.read(file), binding, file)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
begin
|
25
|
-
require 'rake/gempackagetask'
|
26
|
-
rescue LoadError
|
27
|
-
task(:gem) { $stderr.puts '`gem install rake` to package gems' }
|
28
|
-
else
|
29
|
-
Rake::GemPackageTask.new(gemspec) do |pkg|
|
30
|
-
pkg.gem_spec = gemspec
|
31
|
-
end
|
32
|
-
task :gem => :gemspec
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "install the gem locally"
|
36
|
-
task :install => :package do
|
37
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
38
|
-
end
|
39
|
-
|
40
|
-
desc "validate the gemspec"
|
41
|
-
task :gemspec do
|
42
|
-
gemspec.validate
|
43
|
-
end
|
44
|
-
|
45
|
-
task :package => :gemspec
|
data/test/ansel_iconv_test.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class ANSEL::IconvTest < Test::Unit::TestCase
|
6
|
-
FIXTURE_PATH = File.dirname(__FILE__) + "/../../../fixtures/gedcom"
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@ansel = ANSEL::Iconv.new 'UTF-8'
|
10
|
-
end
|
11
|
-
|
12
|
-
should "return ASCII values without conversion" do
|
13
|
-
assert_equal " ", @ansel.iconv("\x20")
|
14
|
-
assert_equal "x", @ansel.iconv("\x78")
|
15
|
-
end
|
16
|
-
|
17
|
-
should "return the unicode replacement character for invalid characters" do
|
18
|
-
assert_equal "�".force_encoding('utf-8'), @ansel.iconv("\xBE\x00")
|
19
|
-
assert_equal "�".force_encoding('utf-8'), @ansel.iconv("\xD1\x00")
|
20
|
-
end
|
21
|
-
|
22
|
-
should "return UTF-8 characters for valid ANSEL characters" do
|
23
|
-
# ANSEL non-combining mappings
|
24
|
-
assert_equal "", @ansel.iconv("\x88\x00")
|
25
|
-
assert_equal "", @ansel.iconv("\x89\x00")
|
26
|
-
assert_equal "", @ansel.iconv("\x8D\x00")
|
27
|
-
assert_equal "", @ansel.iconv("\x8E\x00")
|
28
|
-
assert_equal "Ł".force_encoding('utf-8'), @ansel.iconv("\xA1\x00")
|
29
|
-
assert_equal "Ø".force_encoding('utf-8'), @ansel.iconv("\xA2\x00")
|
30
|
-
assert_equal "Đ".force_encoding('utf-8'), @ansel.iconv("\xA3\x00")
|
31
|
-
assert_equal "Þ".force_encoding('utf-8'), @ansel.iconv("\xA4\x00")
|
32
|
-
assert_equal "Æ".force_encoding('utf-8'), @ansel.iconv("\xA5\x00")
|
33
|
-
assert_equal "Œ".force_encoding('utf-8'), @ansel.iconv("\xA6\x00")
|
34
|
-
assert_equal "ʹ".force_encoding('utf-8'), @ansel.iconv("\xA7\x00")
|
35
|
-
assert_equal "·".force_encoding('utf-8'), @ansel.iconv("\xA8\x00")
|
36
|
-
assert_equal "♭".force_encoding('utf-8'), @ansel.iconv("\xA9\x00")
|
37
|
-
assert_equal "®".force_encoding('utf-8'), @ansel.iconv("\xAA\x00")
|
38
|
-
assert_equal "±".force_encoding('utf-8'), @ansel.iconv("\xAB\x00")
|
39
|
-
assert_equal "±".force_encoding('utf-8'), @ansel.iconv("\xAB\x00")
|
40
|
-
assert_equal "Ơ".force_encoding('utf-8'), @ansel.iconv("\xAC\x00")
|
41
|
-
assert_equal "Ư".force_encoding('utf-8'), @ansel.iconv("\xAD\x00")
|
42
|
-
assert_equal "ʼ".force_encoding('utf-8'), @ansel.iconv("\xAE\x00")
|
43
|
-
assert_equal "ʻ".force_encoding('utf-8'), @ansel.iconv("\xB0\x00")
|
44
|
-
assert_equal "ł".force_encoding('utf-8'), @ansel.iconv("\xB1\x00")
|
45
|
-
assert_equal "ø".force_encoding('utf-8'), @ansel.iconv("\xB2\x00")
|
46
|
-
assert_equal "đ".force_encoding('utf-8'), @ansel.iconv("\xB3\x00")
|
47
|
-
assert_equal "þ".force_encoding('utf-8'), @ansel.iconv("\xB4\x00")
|
48
|
-
assert_equal "æ".force_encoding('utf-8'), @ansel.iconv("\xB5\x00")
|
49
|
-
assert_equal "œ".force_encoding('utf-8'), @ansel.iconv("\xB6\x00")
|
50
|
-
assert_equal "ʺ".force_encoding('utf-8'), @ansel.iconv("\xB7\x00")
|
51
|
-
assert_equal "ı".force_encoding('utf-8'), @ansel.iconv("\xB8\x00")
|
52
|
-
assert_equal "£".force_encoding('utf-8'), @ansel.iconv("\xB9\x00")
|
53
|
-
assert_equal "ð".force_encoding('utf-8'), @ansel.iconv("\xBA\x00")
|
54
|
-
assert_equal "ơ".force_encoding('utf-8'), @ansel.iconv("\xBC\x00")
|
55
|
-
assert_equal "ư".force_encoding('utf-8'), @ansel.iconv("\xBD\x00")
|
56
|
-
assert_equal "°".force_encoding('utf-8'), @ansel.iconv("\xC0\x00")
|
57
|
-
assert_equal "ℓ".force_encoding('utf-8'), @ansel.iconv("\xC1\x00")
|
58
|
-
assert_equal "℗".force_encoding('utf-8'), @ansel.iconv("\xC2\x00")
|
59
|
-
assert_equal "©".force_encoding('utf-8'), @ansel.iconv("\xC3\x00")
|
60
|
-
assert_equal "♯".force_encoding('utf-8'), @ansel.iconv("\xC4\x00")
|
61
|
-
assert_equal "¿".force_encoding('utf-8'), @ansel.iconv("\xC5\x00")
|
62
|
-
assert_equal "¡".force_encoding('utf-8'), @ansel.iconv("\xC6\x00")
|
63
|
-
assert_equal "ß".force_encoding('utf-8'), @ansel.iconv("\xC7\x00")
|
64
|
-
assert_equal "€".force_encoding('utf-8'), @ansel.iconv("\xC8\x00")
|
65
|
-
|
66
|
-
# ANSEL combining characters
|
67
|
-
assert_equal "Ả".force_encoding('utf-8'), @ansel.iconv("\xE0\x41")
|
68
|
-
assert_equal "Ḻ".force_encoding('utf-8'), @ansel.iconv("\xF6\x4C")
|
69
|
-
assert_equal "̲".force_encoding('utf-8'), @ansel.iconv("\xF6")
|
70
|
-
assert_equal "̮".force_encoding('utf-8'), @ansel.iconv("\xF9")
|
71
|
-
assert_equal "Ḫ".force_encoding('utf-8'), @ansel.iconv("\xF9\x48")
|
72
|
-
assert_equal "Ậ".force_encoding('utf-8'), @ansel.iconv("\xF2\xE3\x41")
|
73
|
-
assert_equal "ỵ".force_encoding('utf-8'), @ansel.iconv("\xF2\x79")
|
74
|
-
assert_equal "̣".force_encoding('utf-8'), @ansel.iconv("\xF2")
|
75
|
-
end
|
76
|
-
|
77
|
-
should "convert full text correctly" do
|
78
|
-
assert_equal "What is the question?", @ansel.iconv("What is the question?")
|
79
|
-
assert_equal "¿What is the question?".force_encoding('utf-8'), @ansel.iconv("\xC5\x00What is the question?")
|
80
|
-
assert_equal "© 1994".force_encoding('utf-8'), @ansel.iconv("\xC3\x00 1994")
|
81
|
-
assert_equal "£4.59".force_encoding('utf-8'), @ansel.iconv("\xB9\x004.59")
|
82
|
-
end
|
83
|
-
|
84
|
-
should "convert ANSEL to UTF-16" do
|
85
|
-
converter = ANSEL::Iconv.new 'UTF-16', 'ANSEL'
|
86
|
-
assert_equal "\376\377\000a\000b\000c", converter.iconv('abc')
|
87
|
-
end
|
88
|
-
|
89
|
-
should "convert ASCII to UTF-16" do
|
90
|
-
converter = ANSEL::Iconv.new 'UTF-16', 'ASCII'
|
91
|
-
assert_equal "\376\377\000a\000b\000c", converter.iconv('abc')
|
92
|
-
end
|
93
|
-
|
94
|
-
should "convert UTF-8 to UTF-16" do
|
95
|
-
converter = ANSEL::Iconv.new 'UTF-16', 'UTF-8'
|
96
|
-
assert_equal "\376\377\000a\000b\000c", converter.iconv('abc')
|
97
|
-
end
|
98
|
-
|
99
|
-
should "convert UTF-16 to UTF-16" do
|
100
|
-
converter = ANSEL::Iconv.new 'UTF-16', 'UTF-16'
|
101
|
-
assert_equal "\376\377\000a\000b\000c", converter.iconv("\376\377\000a\000b\000c")
|
102
|
-
end
|
103
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
|
3
|
-
$:.unshift(File.dirname(__FILE__) + "/../lib/")
|
4
|
-
require 'rubygems'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'shoulda'
|
7
|
-
require 'ansel_iconv'
|
8
|
-
|
9
|
-
if RUBY_VERSION < '1.9'
|
10
|
-
class String
|
11
|
-
def force_encoding(e)
|
12
|
-
self
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|