code-pages 1.0.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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Rakefile +24 -0
  4. data/code-pages.gemspec +18 -0
  5. data/lib/code-pages.rb +1 -0
  6. data/lib/code-pages/code_page.rb +20 -0
  7. data/lib/code-pages/importer.rb +67 -0
  8. data/lib/code-pages/version.rb +3 -0
  9. data/lib/code_pages.rb +38 -0
  10. data/resources/10000.yml +256 -0
  11. data/resources/10006.yml +256 -0
  12. data/resources/10007.yml +257 -0
  13. data/resources/10029.yml +257 -0
  14. data/resources/10079.yml +256 -0
  15. data/resources/10081.yml +255 -0
  16. data/resources/1026.yml +257 -0
  17. data/resources/1250.yml +252 -0
  18. data/resources/1251.yml +256 -0
  19. data/resources/1252.yml +252 -0
  20. data/resources/1253.yml +240 -0
  21. data/resources/1254.yml +250 -0
  22. data/resources/1255.yml +234 -0
  23. data/resources/1256.yml +257 -0
  24. data/resources/1257.yml +245 -0
  25. data/resources/1258.yml +248 -0
  26. data/resources/28591.yml +257 -0
  27. data/resources/28592.yml +257 -0
  28. data/resources/28593.yml +250 -0
  29. data/resources/28594.yml +257 -0
  30. data/resources/28595.yml +257 -0
  31. data/resources/28596.yml +212 -0
  32. data/resources/28597.yml +254 -0
  33. data/resources/28598.yml +221 -0
  34. data/resources/28599.yml +257 -0
  35. data/resources/28600.yml +257 -0
  36. data/resources/28601.yml +249 -0
  37. data/resources/28603.yml +257 -0
  38. data/resources/28604.yml +257 -0
  39. data/resources/28605.yml +257 -0
  40. data/resources/28606.yml +257 -0
  41. data/resources/37.yml +257 -0
  42. data/resources/437.yml +257 -0
  43. data/resources/47451.yml +257 -0
  44. data/resources/500.yml +257 -0
  45. data/resources/737.yml +257 -0
  46. data/resources/775.yml +257 -0
  47. data/resources/850.yml +257 -0
  48. data/resources/852.yml +257 -0
  49. data/resources/855.yml +257 -0
  50. data/resources/857.yml +254 -0
  51. data/resources/860.yml +257 -0
  52. data/resources/861.yml +257 -0
  53. data/resources/862.yml +257 -0
  54. data/resources/863.yml +257 -0
  55. data/resources/864.yml +251 -0
  56. data/resources/865.yml +257 -0
  57. data/resources/866.yml +257 -0
  58. data/resources/869.yml +248 -0
  59. data/resources/874.yml +226 -0
  60. data/resources/875.yml +257 -0
  61. data/resources/932.yml +7916 -0
  62. data/resources/936.yml +21921 -0
  63. data/resources/949.yml +17177 -0
  64. data/resources/950.yml +13632 -0
  65. data/resources/code_page_manifest.yml +110 -0
  66. data/spec/code_page_spec.rb +22 -0
  67. data/spec/code_pages_spec.rb +49 -0
  68. data/spec/spec_helper.rb +8 -0
  69. metadata +110 -0
@@ -0,0 +1,110 @@
1
+ - code_page: 37
2
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT
3
+ - code_page: 437
4
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT
5
+ - code_page: 500
6
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT
7
+ - code_page: 737
8
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP737.TXT
9
+ - code_page: 775
10
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP775.TXT
11
+ - code_page: 850
12
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP850.TXT
13
+ - code_page: 852
14
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP852.TXT
15
+ - code_page: 855
16
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP855.TXT
17
+ - code_page: 857
18
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP857.TXT
19
+ - code_page: 860
20
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP860.TXT
21
+ - code_page: 861
22
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP861.TXT
23
+ - code_page: 862
24
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP862.TXT
25
+ - code_page: 863
26
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP863.TXT
27
+ - code_page: 864
28
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP864.TXT
29
+ - code_page: 865
30
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP865.TXT
31
+ - code_page: 866
32
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP866.TXT
33
+ - code_page: 869
34
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP869.TXT
35
+ - code_page: 874
36
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP874.TXT
37
+ - code_page: 875
38
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP875.TXT
39
+ - code_page: 932
40
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT
41
+ - code_page: 936
42
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
43
+ - code_page: 949
44
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT
45
+ - code_page: 950
46
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT
47
+ - code_page: 1026
48
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP1026.TXT
49
+ - code_page: 1250
50
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT
51
+ - code_page: 1251
52
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT
53
+ - code_page: 1252
54
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
55
+ - code_page: 1253
56
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1253.TXT
57
+ - code_page: 1254
58
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1254.TXT
59
+ - code_page: 1255
60
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT
61
+ - code_page: 1256
62
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT
63
+ - code_page: 1257
64
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT
65
+ - code_page: 1258
66
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT
67
+ - code_page: 47451
68
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/ATARIST.TXT
69
+ - code_page: 10000
70
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/ROMAN.TXT
71
+ - code_page: 10006
72
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/GREEK.TXT
73
+ - code_page: 10007
74
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/CYRILLIC.TXT
75
+ - code_page: 10029
76
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/LATIN2.TXT
77
+ - code_page: 10079
78
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/ICELAND.TXT
79
+ - code_page: 10081
80
+ url: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/TURKISH.TXT
81
+ - code_page: 28591
82
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT
83
+ - code_page: 28592
84
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT
85
+ - code_page: 28593
86
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-3.TXT
87
+ - code_page: 28594
88
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-4.TXT
89
+ - code_page: 28595
90
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-5.TXT
91
+ - code_page: 28596
92
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-6.TXT
93
+ - code_page: 28597
94
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-7.TXT
95
+ - code_page: 28598
96
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-8.TXT
97
+ - code_page: 28599
98
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-9.TXT
99
+ - code_page: 28600
100
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-10.TXT
101
+ - code_page: 28601
102
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-11.TXT
103
+ - code_page: 28603
104
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-13.TXT
105
+ - code_page: 28604
106
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-14.TXT
107
+ - code_page: 28605
108
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-15.TXT
109
+ - code_page: 28606
110
+ url: http://www.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe CodePages::CodePage do
4
+ let(:code_page) { CodePages[37] }
5
+
6
+ describe '#unicode_mapping' do
7
+ subject { code_page.unicode_mapping }
8
+
9
+ it 'maps code page characters to unicode code points' do
10
+ expect(subject[4]).to eq(156)
11
+ expect(subject[120]).to eq(204)
12
+ expect(subject[242]).to eq(50)
13
+ expect(subject[255]).to eq(159)
14
+ end
15
+ end
16
+
17
+ describe '#to_utf8' do
18
+ it 'converts the given string from the code page to utf8' do
19
+ expect(code_page.to_utf8('abc')).to eq('/ÂÄ')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe CodePages do
4
+ describe '#[]' do
5
+ subject { described_class[875] }
6
+
7
+ it 'retrieves code pages by id' do
8
+ expect(subject).to be_a(CodePages::CodePage)
9
+ expect(subject.id).to eq(875)
10
+ end
11
+ end
12
+
13
+ describe '#supported_ids' do
14
+ subject { described_class.supported_ids }
15
+
16
+ it 'rerieves a list of all available code page ids' do
17
+ expect(subject.all? { |id| id.is_a?(Integer) }).to eq(true)
18
+ expect(subject).to include(875)
19
+ expect(subject).to include(10006)
20
+ expect(subject).to include(1251)
21
+ end
22
+ end
23
+
24
+ describe '#supports?' do
25
+ it 'returns true if the code page is supported' do
26
+ expect(described_class.supports?(28605)).to eq(true)
27
+ end
28
+
29
+ it 'returns false if the code page is not supported' do
30
+ expect(described_class.supports?(38)).to eq(false)
31
+ end
32
+ end
33
+
34
+ describe '#all' do
35
+ subject { described_class.all }
36
+
37
+ it 'returns a hash of all code pages' do
38
+ subject.each_pair do |_, code_page|
39
+ expect(code_page).to be_a(CodePages::CodePage)
40
+ end
41
+ end
42
+
43
+ it 'includes certain code pages' do
44
+ expect(subject).to include(950)
45
+ expect(subject).to include(47451)
46
+ expect(subject).to include(1258)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,8 @@
1
+ $:.push(File.dirname(__FILE__))
2
+
3
+ require 'rspec'
4
+ require 'pry-byebug'
5
+ require 'code-pages'
6
+
7
+ RSpec.configure do |config|
8
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code-pages
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cameron Dutro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A database of legacy Microsoft and ISO 8859 code pages for Ruby.
14
+ email:
15
+ - camertron@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - Rakefile
22
+ - code-pages.gemspec
23
+ - lib/code-pages.rb
24
+ - lib/code-pages/code_page.rb
25
+ - lib/code-pages/importer.rb
26
+ - lib/code-pages/version.rb
27
+ - lib/code_pages.rb
28
+ - resources/10000.yml
29
+ - resources/10006.yml
30
+ - resources/10007.yml
31
+ - resources/10029.yml
32
+ - resources/10079.yml
33
+ - resources/10081.yml
34
+ - resources/1026.yml
35
+ - resources/1250.yml
36
+ - resources/1251.yml
37
+ - resources/1252.yml
38
+ - resources/1253.yml
39
+ - resources/1254.yml
40
+ - resources/1255.yml
41
+ - resources/1256.yml
42
+ - resources/1257.yml
43
+ - resources/1258.yml
44
+ - resources/28591.yml
45
+ - resources/28592.yml
46
+ - resources/28593.yml
47
+ - resources/28594.yml
48
+ - resources/28595.yml
49
+ - resources/28596.yml
50
+ - resources/28597.yml
51
+ - resources/28598.yml
52
+ - resources/28599.yml
53
+ - resources/28600.yml
54
+ - resources/28601.yml
55
+ - resources/28603.yml
56
+ - resources/28604.yml
57
+ - resources/28605.yml
58
+ - resources/28606.yml
59
+ - resources/37.yml
60
+ - resources/437.yml
61
+ - resources/47451.yml
62
+ - resources/500.yml
63
+ - resources/737.yml
64
+ - resources/775.yml
65
+ - resources/850.yml
66
+ - resources/852.yml
67
+ - resources/855.yml
68
+ - resources/857.yml
69
+ - resources/860.yml
70
+ - resources/861.yml
71
+ - resources/862.yml
72
+ - resources/863.yml
73
+ - resources/864.yml
74
+ - resources/865.yml
75
+ - resources/866.yml
76
+ - resources/869.yml
77
+ - resources/874.yml
78
+ - resources/875.yml
79
+ - resources/932.yml
80
+ - resources/936.yml
81
+ - resources/949.yml
82
+ - resources/950.yml
83
+ - resources/code_page_manifest.yml
84
+ - spec/code_page_spec.rb
85
+ - spec/code_pages_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: http://github.com/camertron/code-pages
88
+ licenses: []
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.6.13
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A database of legacy Microsoft and ISO 8859 code pages for Ruby.
110
+ test_files: []