ansel_iconv 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.1.2
2
+
3
+ * Speed up conversion
4
+
1
5
  == 1.1.0
2
6
 
3
7
  * Ruby 1.9 compatibility
data/README.markdown CHANGED
@@ -12,7 +12,7 @@ Copyright (c) 2006-2010 Keith Morrison <mailto:keithm@infused.org>, <http://www.
12
12
 
13
13
  ## Compatibility
14
14
 
15
- ANSEL::Iconv is compatible with Ruby 1.8.6, 1.8.7 and 1.9.1
15
+ ANSEL::Iconv is compatible with Ruby 1.8.6, 1.8.7, and 1.9.2
16
16
 
17
17
  ## Installation
18
18
 
@@ -21,14 +21,21 @@ ANSEL::Iconv is compatible with Ruby 1.8.6, 1.8.7 and 1.9.1
21
21
  ## Basic Usage
22
22
 
23
23
  Conversion from ANSEL to any other encoding is fully supported, but you cannot
24
- currently convert to ANSEL from another encoding. Two-way encoding will be added
25
- in a future release.
24
+ convert to ANSEL from another encoding. Two-way encoding may be added
25
+ in the future.
26
26
 
27
27
  require 'ansel_iconv'
28
28
 
29
- # Convert ANSEL to UTF-8
30
- @ansel = ANSEL::Iconv.new 'UTF-8'
31
- @ansel.iconv("\xB9\x004.59") # => "£4.59"
29
+ # convert ANSEL to UTF-8
30
+ converter = ANSEL::Iconv.new 'UTF-8'
31
+ converter.iconv("\xB9\x004.59") # => "£4.59"
32
+
33
+ You can use ANSEL::Iconv as a replacement for the built-in Iconv, because
34
+ non-ANSEL conversions are simply passed through to Iconv.
35
+
36
+ # convert UTF-8 to UTF-16
37
+ converter = ANSEL::Iconv.new 'UTF-16', 'UTF-8'
38
+ converter.iconv("£4.59") # => "\376\377\000\243\0004\000.\0005\0009"
32
39
 
33
40
  ## About the ANSEL character set
34
41
 
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :major: 1
4
2
  :minor: 1
3
+ :build:
4
+ :patch: 2
5
+ :major: 1
data/ansel_iconv.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ansel_iconv}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Keith Morrison"]
12
- s.date = %q{2010-04-07}
12
+ s.date = %q{2010-05-28}
13
13
  s.description = %q{Convert ANSEL encoded text to any other encoding available to Iconv}
14
14
  s.email = %q{keithm@infused.org}
15
15
  s.extra_rdoc_files = [
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.homepage = %q{http://github.com/infused/ansel_iconv}
29
29
  s.rdoc_options = ["--charset=UTF-8"]
30
30
  s.require_paths = ["lib"]
31
- s.rubygems_version = %q{1.3.6}
31
+ s.rubygems_version = %q{1.3.7}
32
32
  s.summary = %q{Convert ANSEL encoded text}
33
33
  s.test_files = [
34
34
  "test/ansel_iconv_test.rb",
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
40
  s.specification_version = 3
41
41
 
42
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
43
  s.add_runtime_dependency(%q<activesupport>, ["= 2.3.5"])
44
44
  else
45
45
  s.add_dependency(%q<activesupport>, ["= 2.3.5"])
@@ -48,3 +48,4 @@ Gem::Specification.new do |s|
48
48
  s.add_dependency(%q<activesupport>, ["= 2.3.5"])
49
49
  end
50
50
  end
51
+
data/lib/ansel_iconv.rb CHANGED
@@ -589,16 +589,17 @@ module ANSEL
589
589
  scanner = StringScanner.new(string)
590
590
  until scanner.eos? do
591
591
  byte = scanner.get_byte
592
+ char = byte.unpack('C')[0]
592
593
 
593
- if byte.unpack('C')[0] <= 0x7F
594
+ if char <= 0x7F
594
595
  output << byte
595
- elsif byte.unpack('C')[0] >= 0x88 && byte.unpack('C')[0] <= 0xC8
596
- hex_key = byte.unpack('C')[0].to_s(16).upcase
596
+ elsif char >= 0x88 && char <= 0xC8
597
+ hex_key = char.to_s(16).upcase
597
598
  output << ::Iconv.conv(@to_charset, 'UTF-16', @ansi_to_utf8.has_key?(hex_key) ? @ansi_to_utf8[hex_key] : @ansi_to_utf8['ERR'])
598
599
  scanner.get_byte # ignore the next byte
599
- elsif byte.unpack('C')[0] >= 0xE0 && byte.unpack('C')[0] <= 0xFB
600
+ elsif char >= 0xE0 && char <= 0xFB
600
601
  [2, 1, 0].each do |n| # try 3 bytes, then 2 bytes, then 1 byte
601
- bytes = [byte.unpack('C')[0].to_s(16).upcase]
602
+ bytes = [char.to_s(16).upcase]
602
603
  scanner.peek(n).each_byte {|b| bytes << b.to_s(16).upcase}
603
604
  hex_key = bytes.join("+")
604
605
  if @ansi_to_utf8.has_key?(hex_key)
@@ -615,20 +616,6 @@ module ANSEL
615
616
 
616
617
  @to_charset == 'UTF-8' ? output : ::Iconv.conv(@to_charset, 'UTF-8', output)
617
618
  end
618
-
619
- def convert_char(char)
620
- return char if char.size <= 1 && char[0] <= 0x7f
621
-
622
- if char[0] > 0x7f && char[0] < 0xE0
623
- hex_key = char[0].to_s(16).upcase
624
- elsif char[0] >= 0xE0
625
- bytes = []
626
- char.each_byte {|byte| bytes << byte.to_s(16).upcase}
627
- hex_key = bytes.join('+')
628
- end
629
- return ::Iconv.conv(@to_charset, 'UTF-16', @ansi_to_utf8.has_key?(hex_key) ? @ansi_to_utf8[hex_key] : @ansi_to_utf8['ERR'])
630
- end
631
-
619
+
632
620
  end
633
-
634
621
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ansel_iconv
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 1
8
- - 0
9
- version: 1.1.0
9
+ - 2
10
+ version: 1.1.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Keith Morrison
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-07 00:00:00 -07:00
18
+ date: 2010-05-28 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: activesupport
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - "="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 9
27
30
  segments:
28
31
  - 2
29
32
  - 3
@@ -58,23 +61,27 @@ rdoc_options:
58
61
  require_paths:
59
62
  - lib
60
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
61
65
  requirements:
62
66
  - - ">="
63
67
  - !ruby/object:Gem::Version
68
+ hash: 3
64
69
  segments:
65
70
  - 0
66
71
  version: "0"
67
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
68
74
  requirements:
69
75
  - - ">="
70
76
  - !ruby/object:Gem::Version
77
+ hash: 3
71
78
  segments:
72
79
  - 0
73
80
  version: "0"
74
81
  requirements: []
75
82
 
76
83
  rubyforge_project:
77
- rubygems_version: 1.3.6
84
+ rubygems_version: 1.3.7
78
85
  signing_key:
79
86
  specification_version: 3
80
87
  summary: Convert ANSEL encoded text