gsm_tools 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p290@gsm_tools"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+ #
14
+ # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
15
+ #
16
+ # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
17
+ #
18
+
19
+ #
20
+ # First we attempt to load the desired environment directly from the environment
21
+ # file. This is very fast and efficient compared to running through the entire
22
+ # CLI and selector. If you want feedback on which environment was used then
23
+ # insert the word 'use' after --create as this triggers verbose mode.
24
+ #
25
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
26
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
27
+ then
28
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
29
+
30
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
31
+ then
32
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
33
+ fi
34
+ else
35
+ # If the environment file has not yet been created, use the RVM CLI to select.
36
+ if ! rvm --create "$environment_id"
37
+ then
38
+ echo "Failed to create RVM environment '${environment_id}'."
39
+ return 1
40
+ fi
41
+ fi
42
+
43
+ #
44
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
45
+ # it be automatically loaded. Uncomment the following and adjust the filename if
46
+ # necessary.
47
+ #
48
+ # filename=".gems"
49
+ # if [[ -s "$filename" ]]
50
+ # then
51
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
52
+ # fi
53
+
54
+ # If you use bundler, this might be useful to you:
55
+ # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
56
+ # then
57
+ # printf "The rubygem 'bundler' is not installed. Installing it now.\n"
58
+ # gem install bundler
59
+ # fi
60
+ # if [[ -s Gemfile ]] && command -v bundle
61
+ # then
62
+ # bundle install
63
+ # fi
64
+
65
+ if [[ $- == *i* ]] # check for interactive shells
66
+ then
67
+ echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
68
+ else
69
+ echo "Using: $GEM_HOME" # don't use colors in interactive shells
70
+ fi
71
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gsm_tools.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ end
10
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/gsm_tools.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gsm_tools/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gsm_tools"
7
+ s.version = GsmTools::VERSION
8
+ s.authors = ["Andrew Ang"]
9
+ s.email = ["andukz@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{GSM 03.38 extension libraries}
12
+ s.description = %q{Adds various methods to check GSM 03.38 character encoding compatibility.}
13
+
14
+ s.rubyforge_project = "gsm_tools"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+
25
+ s.add_development_dependency "rspec"
26
+ s.add_development_dependency "guard-rspec"
27
+ end
@@ -0,0 +1,235 @@
1
+ #encoding: utf-8
2
+ #
3
+ # Unicode/GSM Reference: http://unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT
4
+
5
+ require 'iconv'
6
+
7
+ module GSMTools
8
+ NL = "\n"
9
+ CR = "\r"
10
+ BS = '\\'
11
+
12
+ NON_GSM_7BIT_MATCHER = /[^@£\$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'\(\)\*\+,-\.\/0123456789:;<=>\?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà\^{}\\\[~\]\|€]/
13
+
14
+ GSM_7BIT_MAP = [
15
+ 0x00, '@'.ord,
16
+ 0x01, '£'.ord,
17
+ 0x02, '$'.ord,
18
+ 0x03, '¥'.ord,
19
+ 0x04, 'è'.ord,
20
+ 0x05, 'é'.ord,
21
+ 0x06, 'ù'.ord,
22
+ 0x07, 'ì'.ord,
23
+ 0x08, 'ò'.ord,
24
+ 0x09, 'Ç'.ord,
25
+ 0x0a, 0x000A,
26
+ 0x0b, 'Ø'.ord,
27
+ 0x0c, 'ø'.ord,
28
+ 0x0d, 0x000D,
29
+ 0x0e, 'Å'.ord,
30
+ 0x0f, 'å'.ord,
31
+ 0x10, 'Δ'.ord,
32
+ 0x11, '_'.ord,
33
+ 0x12, 'Φ'.ord,
34
+ 0x13, 'Γ'.ord,
35
+ 0x14, 'Λ'.ord,
36
+ 0x15, 'Ω'.ord,
37
+ 0x16, 'Π'.ord,
38
+ 0x17, 'Ψ'.ord,
39
+ 0x18, 'Σ'.ord,
40
+ 0x19, 'Θ'.ord,
41
+ 0x1a, 'Ξ'.ord,
42
+ 0x1b, 0x00A0,
43
+ 0x1c, 'Æ'.ord,
44
+ 0x1d, 'æ'.ord,
45
+ 0x1e, 'ß'.ord,
46
+ 0x1f, 'É'.ord,
47
+ 0x20, " ".ord,
48
+ 0x21, '!'.ord,
49
+ 0x22, '"'.ord,
50
+ 0x23, '#'.ord,
51
+ 0x24, '¤'.ord,
52
+ 0x25, '%'.ord,
53
+ 0x26, '&'.ord,
54
+ 0x27, "'".ord,
55
+ 0x28, '('.ord,
56
+ 0x29, ')'.ord,
57
+ 0x2a, '*'.ord,
58
+ 0x2b, '+'.ord,
59
+ 0x2c, ','.ord,
60
+ 0x2d, '-'.ord,
61
+ 0x2e, '.'.ord,
62
+ 0x2f, '/'.ord,
63
+ 0x30, '0'.ord,
64
+ 0x31, '1'.ord,
65
+ 0x32, '2'.ord,
66
+ 0x33, '3'.ord,
67
+ 0x34, '4'.ord,
68
+ 0x35, '5'.ord,
69
+ 0x36, '6'.ord,
70
+ 0x37, '7'.ord,
71
+ 0x38, '8'.ord,
72
+ 0x39, '9'.ord,
73
+ 0x3a, ':'.ord,
74
+ 0x3b, ';'.ord,
75
+ 0x3c, '<'.ord,
76
+ 0x3d, '='.ord,
77
+ 0x3e, '>'.ord,
78
+ 0x3f, '?'.ord,
79
+ 0x40, '¡'.ord,
80
+ 0x41, 'A'.ord,
81
+ 0x42, 'B'.ord,
82
+ 0x43, 'C'.ord,
83
+ 0x44, 'D'.ord,
84
+ 0x45, 'E'.ord,
85
+ 0x46, 'F'.ord,
86
+ 0x47, 'G'.ord,
87
+ 0x48, 'H'.ord,
88
+ 0x49, 'I'.ord,
89
+ 0x4a, 'J'.ord,
90
+ 0x4b, 'K'.ord,
91
+ 0x4c, 'L'.ord,
92
+ 0x4d, 'M'.ord,
93
+ 0x4e, 'N'.ord,
94
+ 0x4f, 'O'.ord,
95
+ 0x50, 'P'.ord,
96
+ 0x51, 'Q'.ord,
97
+ 0x52, 'R'.ord,
98
+ 0x53, 'S'.ord,
99
+ 0x54, 'T'.ord,
100
+ 0x55, 'U'.ord,
101
+ 0x56, 'V'.ord,
102
+ 0x57, 'W'.ord,
103
+ 0x58, 'X'.ord,
104
+ 0x59, 'Y'.ord,
105
+ 0x5a, 'Z'.ord,
106
+ 0x5b, 'Ä'.ord,
107
+ 0x5c, 'Ö'.ord,
108
+ 0x5d, 'Ñ'.ord,
109
+ 0x5e, 'Ü'.ord,
110
+ 0x5f, '§'.ord,
111
+ 0x60, '¿'.ord,
112
+ 0x61, 'a'.ord,
113
+ 0x62, 'b'.ord,
114
+ 0x63, 'c'.ord,
115
+ 0x64, 'd'.ord,
116
+ 0x65, 'e'.ord,
117
+ 0x66, 'f'.ord,
118
+ 0x67, 'g'.ord,
119
+ 0x68, 'h'.ord,
120
+ 0x69, 'i'.ord,
121
+ 0x6a, 'j'.ord,
122
+ 0x6b, 'k'.ord,
123
+ 0x6c, 'l'.ord,
124
+ 0x6d, 'm'.ord,
125
+ 0x6e, 'n'.ord,
126
+ 0x6f, 'o'.ord,
127
+ 0x70, 'p'.ord,
128
+ 0x71, 'q'.ord,
129
+ 0x72, 'r'.ord,
130
+ 0x73, 's'.ord,
131
+ 0x74, 't'.ord,
132
+ 0x75, 'u'.ord,
133
+ 0x76, 'v'.ord,
134
+ 0x77, 'w'.ord,
135
+ 0x78, 'x'.ord,
136
+ 0x79, 'y'.ord,
137
+ 0x7a, 'z'.ord,
138
+ 0x7b, 'ä'.ord,
139
+ 0x7c, 'ö'.ord,
140
+ 0x7d, 'ñ'.ord,
141
+ 0x7e, 'ü'.ord,
142
+ 0x7f, 'à'.ord,
143
+ #[0x1B, 0x0A], 0x000C, # Removed for now, Need to figure out how to Regex match this character
144
+ [0x1B, 0x14], '^'.ord,
145
+ [0x1B, 0x28], '{'.ord,
146
+ [0x1B, 0x29], '}'.ord,
147
+ [0x1B, 0x2f], 0x005C,
148
+ [0x1B, 0x3c], '['.ord,
149
+ [0x1B, 0x3d], '~'.ord,
150
+ [0x1B, 0x3e], ']'.ord,
151
+ [0x1B, 0x40], '|'.ord,
152
+ [0x1B, 0x65], '€'.ord
153
+ ]
154
+
155
+ @@uni_to_gsm = Hash.new
156
+ @@gsm_to_uni = Hash.new
157
+ GSM_7BIT_MAP.each_slice(2) { |gsm, uni| @@uni_to_gsm[uni] = gsm; @@gsm_to_uni[gsm] = uni; }
158
+
159
+ class << self
160
+ def is_gsm_7bit? str
161
+ str.match(NON_GSM_7BIT_MATCHER).nil?
162
+ end
163
+
164
+ def to_gsm str
165
+ if self.is_gsm_7bit?(str)
166
+ str.unpack('U*').collect { |utf8_char| @@uni_to_gsm[utf8_char] }.flatten.pack('c*')
167
+ else
168
+ Iconv.iconv('UCS-2', 'UTF-8', str).first
169
+ end
170
+ end
171
+
172
+ def gsm_string_counter str
173
+ hash = {}
174
+
175
+ if self.is_gsm_7bit?(str)
176
+ hash = { :length => 0, :segments => 1, :remaining_length_for_segment => 160 }
177
+ gsm_str = self.to_gsm(str)
178
+ hash[:length] = gsm_str.length
179
+
180
+ case gsm_str.length
181
+ when 0..160
182
+ hash[:segments] = 1
183
+ hash[:remaining_length_for_segment] = 160 - gsm_str.length
184
+ when 161..306
185
+ hash[:segments] = 2
186
+ hash[:remaining_length_for_segment] = 306 - gsm_str.length
187
+ when 307..459
188
+ hash[:segments] = 3
189
+ hash[:remaining_length_for_segment] = 459 - gsm_str.length
190
+ else
191
+ hash = { :invalid => true }
192
+ end
193
+
194
+ else
195
+ hash = { :length => 0, :segments => 1, :remaining_length_for_segment => 70 }
196
+ hash[:length] = str.length
197
+
198
+ case str.length
199
+ when 0..70
200
+ hash[:segments] = 1
201
+ hash[:remaining_length_for_segment] = 70 - str.length
202
+ when 71..134
203
+ hash[:segments] = 2
204
+ hash[:remaining_length_for_segment] = 134 - str.length
205
+ when 135..201
206
+ hash[:segments] = 3
207
+ hash[:remaining_length_for_segment] = 201 - str.length
208
+ else
209
+ hash = { :invalid => true }
210
+ end
211
+ end
212
+
213
+ return hash
214
+ end
215
+
216
+ def gsm_to_s gsm
217
+ last_is_escape = false
218
+ collect = gsm.unpack('c*').collect do |bin_char|
219
+ if bin_char == 27
220
+ last_is_escape = true
221
+ next
222
+ end
223
+
224
+ if last_is_escape
225
+ last_is_escape = false
226
+ @@gsm_to_uni[[27, bin_char]]
227
+ else
228
+ @@gsm_to_uni[bin_char]
229
+ end
230
+ end
231
+ collect.reject { |x| x.nil? }.flatten.pack('U*')
232
+ end
233
+
234
+ end
235
+ end
@@ -0,0 +1,11 @@
1
+ module GSMTools
2
+ module String
3
+ def to_gsm
4
+ GSMTools.to_gsm self
5
+ end
6
+ end
7
+ end
8
+
9
+ class String
10
+ include GSMTools::String
11
+ end
@@ -0,0 +1,3 @@
1
+ module GsmTools
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gsm_tools.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "gsm_tools/version"
2
+ require "gsm_tools/base"
3
+ require "gsm_tools/string"
@@ -0,0 +1,81 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe GSMTools, "base" do
6
+ it "must check for correct non-GSM 7-bit string" do
7
+ GSMTools.is_gsm_7bit?(GSM_7BIT_CHARS).should == true
8
+ GSMTools.is_gsm_7bit?("你好").should == false
9
+ end
10
+
11
+ it "must encode the correct unicode chars to GSM 7-bit" do
12
+ GSM_UNICODE_MAP.each_slice(2) do |gsm, unicode|
13
+ GSMTools.is_gsm_7bit?(unicode.chr('UTF-8')).should == true
14
+ result = GSMTools.to_gsm(unicode.chr('UTF-8'))
15
+ (result.length == 1 ? (result.ord.should == gsm) : result.bytes.collect {|x| x }.should == gsm)
16
+ end
17
+ end
18
+
19
+ it "must be able to decode form GSM 7-bit" do
20
+ gsm_7bit = GSMTools.to_gsm(GSM_7BIT_CHARS)
21
+ reverted = GSMTools.gsm_to_s(gsm_7bit)
22
+ reverted.should == GSM_7BIT_CHARS
23
+ end
24
+
25
+ it "must calculate the length of GSM 7-bit string properly" do
26
+ gsm_7bit = GSMTools.to_gsm("0123456789abcde")
27
+ gsm_7bit.length.should == 15
28
+ gsm_7bit = GSMTools.to_gsm("0123456789abcde[]{}~")
29
+ gsm_7bit.length.should == 25
30
+ end
31
+
32
+ it "must encode non GSM 7-bit characters to UCS-2" do
33
+ GSMTools.to_gsm("你好").length.should == 4
34
+ end
35
+
36
+ it "must check the length and segments of the GSM string" do
37
+ GSMTools.gsm_string_counter("hello there").should == { :length => 11,
38
+ :segments => 1,
39
+ :remaining_length_for_segment => 149 }
40
+
41
+ GSMTools.gsm_string_counter("Andreasen gag high friggin Argyll Argyll artful Tyrol archon stock serial studbook Argyll Argyll archbishop drink sitcom restful Argyll stubborn objects scoffs actinolite quinta stump pigs electric").should == { :length => 197,
42
+ :segments => 2,
43
+ :remaining_length_for_segment => 109 }
44
+
45
+ GSMTools.gsm_string_counter("Axndreasen gag high friggin Argyll Argyll artful Tyrol archon stock serial studbook Argyll Argyll archbishop drink sitcom restful Argyll stubborn objects scoffs actinolite quinta stump pigs electric andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang").should == { :length => 306,
46
+ :segments => 2,
47
+ :remaining_length_for_segment => 0 }
48
+
49
+ GSMTools.gsm_string_counter("Axndreasen gag high friggin Argyll Argyll artful Tyrol archon stock serial studbook Argyll Argyll archbishop drink sitcom restful Argyll stubborn objects scoffs actinolite quinta stump pigs electric andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo an[").should == { :length => 307,
50
+ :segments => 3,
51
+ :remaining_length_for_segment => 152 }
52
+
53
+ GSMTools.gsm_string_counter("Andreasen gag high friggin Argyll Argyll artful Tyrol archon stock serial studbook Argyll Argyll archbishop drink sitcom restful Argyll stubborn objects scoffs actinolite quinta stump pigs electric andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang fdafda fdafa dsafsaf dsaf dsaf dsa fs af sa fsa fsdaf dasf dsa f dsaf dsa fds afd sa fdsa fdsafasfdsa fas fd saf da fd afdsafdasfdasf dsaf das f asf as[").should == { :length => 459,
54
+ :segments => 3,
55
+ :remaining_length_for_segment => 0 }
56
+
57
+ GSMTools.gsm_string_counter("Andreasen gag high friggin Argyll Argyll artful Tyrol archon stock serial studbook Argyll Argyll archbishop drink sitcom restful Argyll stubborn objects scoffs actinolite quinta stump pigs electric andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang andrew angelo ang fdafda fdafa dsafsaf dsaf dsaf dsa fs af sa fsa fsdaf dasf dsa f dsaf dsa fds afd sa fdsa fdsafasfdsa fas fd saf da fd afdsafdasfdasf dsaf das f asf as[x").should == { :invalid => true }
58
+
59
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG").should == { :length => 10,
60
+ :segments => 1,
61
+ :remaining_length_for_segment => 60 }
62
+
63
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG").should == { :length => 70,
64
+ :segments => 1,
65
+ :remaining_length_for_segment => 0 }
66
+
67
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG!").should == { :length => 71,
68
+ :segments => 2,
69
+ :remaining_length_for_segment => 63 }
70
+
71
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG!!!!").should == { :length => 134,
72
+ :segments => 2,
73
+ :remaining_length_for_segment => 0 }
74
+
75
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG[").should == { :length => 201,
76
+ :segments => 3,
77
+ :remaining_length_for_segment => 0 }
78
+
79
+ GSMTools.gsm_string_counter("你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG你好我是洪一尧ANG!!").should == { :invalid => true }
80
+ end
81
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSMTools, "string" do
4
+ it "must add the method to_gsm to the String class" do
5
+ "hello".should respond_to(:to_gsm)
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSMTools, "initialize" do
4
+ it "must initialize GSMTools module" do
5
+ GSMTools.class.should == Module
6
+ end
7
+
8
+ it "must initialize GSMTools::String module" do
9
+ GSMTools::String.class.should == Module
10
+ end
11
+ end
@@ -0,0 +1,146 @@
1
+ #encoding: utf-8
2
+
3
+ require 'gsm_tools'
4
+
5
+ GSM_7BIT_CHARS = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà^{}\\[~]|€"
6
+
7
+ GSM_UNICODE_MAP = [
8
+ 0x00, 0x0040, # COMMERCIAL AT
9
+ 0x01, 0x00A3, # POUND SIGN
10
+ 0x02, 0x0024, # DOLLAR SIGN
11
+ 0x03, 0x00A5, # YEN SIGN
12
+ 0x04, 0x00E8, # LATIN SMALL LETTER E WITH GRAVE
13
+ 0x05, 0x00E9, # LATIN SMALL LETTER E WITH ACUTE
14
+ 0x06, 0x00F9, # LATIN SMALL LETTER U WITH GRAVE
15
+ 0x07, 0x00EC, # LATIN SMALL LETTER I WITH GRAVE
16
+ 0x08, 0x00F2, # LATIN SMALL LETTER O WITH GRAVE
17
+ #0x09, 0x00E7, # LATIN SMALL LETTER C WITH CEDILLA
18
+ 0x09, 0x00C7, # LATIN CAPITAL LETTER C WITH CEDILLA (see note above), THIS SHOULD BE THE CORRECT ONE
19
+ 0x0A, 0x000A, # LINE FEED
20
+ 0x0B, 0x00D8, # LATIN CAPITAL LETTER O WITH STROKE
21
+ 0x0C, 0x00F8, # LATIN SMALL LETTER O WITH STROKE
22
+ 0x0D, 0x000D, # CARRIAGE RETURN
23
+ 0x0E, 0x00C5, # LATIN CAPITAL LETTER A WITH RING ABOVE
24
+ 0x0F, 0x00E5, # LATIN SMALL LETTER A WITH RING ABOVE
25
+ 0x10, 0x0394, # GREEK CAPITAL LETTER DELTA
26
+ 0x11, 0x005F, # LOW LINE
27
+ 0x12, 0x03A6, # GREEK CAPITAL LETTER PHI
28
+ 0x13, 0x0393, # GREEK CAPITAL LETTER GAMMA
29
+ 0x14, 0x039B, # GREEK CAPITAL LETTER LAMDA
30
+ 0x15, 0x03A9, # GREEK CAPITAL LETTER OMEGA
31
+ 0x16, 0x03A0, # GREEK CAPITAL LETTER PI
32
+ 0x17, 0x03A8, # GREEK CAPITAL LETTER PSI
33
+ 0x18, 0x03A3, # GREEK CAPITAL LETTER SIGMA
34
+ 0x19, 0x0398, # GREEK CAPITAL LETTER THETA
35
+ 0x1A, 0x039E, # GREEK CAPITAL LETTER XI
36
+ #[0x1B, 0x0A], 0x000C, # FORM FEED # Removed for now, Need to figure out how to Regex match this character
37
+ [0x1B, 0x14], 0x005E, # CIRCUMFLEX ACCENT
38
+ [0x1B, 0x28], 0x007B, # LEFT CURLY BRACKET
39
+ [0x1B, 0x29], 0x007D, # RIGHT CURLY BRACKET
40
+ [0x1B, 0x2F], 0x005C, # REVERSE SOLIDUS
41
+ [0x1B, 0x3C], 0x005B, # LEFT SQUARE BRACKET
42
+ [0x1B, 0x3D], 0x007E, # TILDE
43
+ [0x1B, 0x3E], 0x005D, # RIGHT SQUARE BRACKET
44
+ [0x1B, 0x40], 0x007C, # VERTICAL LINE
45
+ [0x1B, 0x65], 0x20AC, # EURO SIGN
46
+ 0x1C, 0x00C6, # LATIN CAPITAL LETTER AE
47
+ 0x1D, 0x00E6, # LATIN SMALL LETTER AE
48
+ 0x1E, 0x00DF, # LATIN SMALL LETTER SHARP S (German)
49
+ 0x1F, 0x00C9, # LATIN CAPITAL LETTER E WITH ACUTE
50
+ 0x20, 0x0020, # SPACE
51
+ 0x21, 0x0021, # EXCLAMATION MARK
52
+ 0x22, 0x0022, # QUOTATION MARK
53
+ 0x23, 0x0023, # NUMBER SIGN
54
+ 0x24, 0x00A4, # CURRENCY SIGN
55
+ 0x25, 0x0025, # PERCENT SIGN
56
+ 0x26, 0x0026, # AMPERSAND
57
+ 0x27, 0x0027, # APOSTROPHE
58
+ 0x28, 0x0028, # LEFT PARENTHESIS
59
+ 0x29, 0x0029, # RIGHT PARENTHESIS
60
+ 0x2A, 0x002A, # ASTERISK
61
+ 0x2B, 0x002B, # PLUS SIGN
62
+ 0x2C, 0x002C, # COMMA
63
+ 0x2D, 0x002D, # HYPHEN-MINUS
64
+ 0x2E, 0x002E, # FULL STOP
65
+ 0x2F, 0x002F, # SOLIDUS
66
+ 0x30, 0x0030, # DIGIT ZERO
67
+ 0x31, 0x0031, # DIGIT ONE
68
+ 0x32, 0x0032, # DIGIT TWO
69
+ 0x33, 0x0033, # DIGIT THREE
70
+ 0x34, 0x0034, # DIGIT FOUR
71
+ 0x35, 0x0035, # DIGIT FIVE
72
+ 0x36, 0x0036, # DIGIT SIX
73
+ 0x37, 0x0037, # DIGIT SEVEN
74
+ 0x38, 0x0038, # DIGIT EIGHT
75
+ 0x39, 0x0039, # DIGIT NINE
76
+ 0x3A, 0x003A, # COLON
77
+ 0x3B, 0x003B, # SEMICOLON
78
+ 0x3C, 0x003C, # LESS-THAN SIGN
79
+ 0x3D, 0x003D, # EQUALS SIGN
80
+ 0x3E, 0x003E, # GREATER-THAN SIGN
81
+ 0x3F, 0x003F, # QUESTION MARK
82
+ 0x40, 0x00A1, # INVERTED EXCLAMATION MARK
83
+ 0x41, 0x0041, # LATIN CAPITAL LETTER A
84
+ 0x42, 0x0042, # LATIN CAPITAL LETTER B
85
+ 0x43, 0x0043, # LATIN CAPITAL LETTER C
86
+ 0x44, 0x0044, # LATIN CAPITAL LETTER D
87
+ 0x45, 0x0045, # LATIN CAPITAL LETTER E
88
+ 0x46, 0x0046, # LATIN CAPITAL LETTER F
89
+ 0x47, 0x0047, # LATIN CAPITAL LETTER G
90
+ 0x48, 0x0048, # LATIN CAPITAL LETTER H
91
+ 0x49, 0x0049, # LATIN CAPITAL LETTER I
92
+ 0x4A, 0x004A, # LATIN CAPITAL LETTER J
93
+ 0x4B, 0x004B, # LATIN CAPITAL LETTER K
94
+ 0x4C, 0x004C, # LATIN CAPITAL LETTER L
95
+ 0x4D, 0x004D, # LATIN CAPITAL LETTER M
96
+ 0x4E, 0x004E, # LATIN CAPITAL LETTER N
97
+ 0x4F, 0x004F, # LATIN CAPITAL LETTER O
98
+ 0x50, 0x0050, # LATIN CAPITAL LETTER P
99
+ 0x51, 0x0051, # LATIN CAPITAL LETTER Q
100
+ 0x52, 0x0052, # LATIN CAPITAL LETTER R
101
+ 0x53, 0x0053, # LATIN CAPITAL LETTER S
102
+ 0x54, 0x0054, # LATIN CAPITAL LETTER T
103
+ 0x55, 0x0055, # LATIN CAPITAL LETTER U
104
+ 0x56, 0x0056, # LATIN CAPITAL LETTER V
105
+ 0x57, 0x0057, # LATIN CAPITAL LETTER W
106
+ 0x58, 0x0058, # LATIN CAPITAL LETTER X
107
+ 0x59, 0x0059, # LATIN CAPITAL LETTER Y
108
+ 0x5A, 0x005A, # LATIN CAPITAL LETTER Z
109
+ 0x5B, 0x00C4, # LATIN CAPITAL LETTER A WITH DIAERESIS
110
+ 0x5C, 0x00D6, # LATIN CAPITAL LETTER O WITH DIAERESIS
111
+ 0x5D, 0x00D1, # LATIN CAPITAL LETTER N WITH TILDE
112
+ 0x5E, 0x00DC, # LATIN CAPITAL LETTER U WITH DIAERESIS
113
+ 0x5F, 0x00A7, # SECTION SIGN
114
+ 0x60, 0x00BF, # INVERTED QUESTION MARK
115
+ 0x61, 0x0061, # LATIN SMALL LETTER A
116
+ 0x62, 0x0062, # LATIN SMALL LETTER B
117
+ 0x63, 0x0063, # LATIN SMALL LETTER C
118
+ 0x64, 0x0064, # LATIN SMALL LETTER D
119
+ 0x65, 0x0065, # LATIN SMALL LETTER E
120
+ 0x66, 0x0066, # LATIN SMALL LETTER F
121
+ 0x67, 0x0067, # LATIN SMALL LETTER G
122
+ 0x68, 0x0068, # LATIN SMALL LETTER H
123
+ 0x69, 0x0069, # LATIN SMALL LETTER I
124
+ 0x6A, 0x006A, # LATIN SMALL LETTER J
125
+ 0x6B, 0x006B, # LATIN SMALL LETTER K
126
+ 0x6C, 0x006C, # LATIN SMALL LETTER L
127
+ 0x6D, 0x006D, # LATIN SMALL LETTER M
128
+ 0x6E, 0x006E, # LATIN SMALL LETTER N
129
+ 0x6F, 0x006F, # LATIN SMALL LETTER O
130
+ 0x70, 0x0070, # LATIN SMALL LETTER P
131
+ 0x71, 0x0071, # LATIN SMALL LETTER Q
132
+ 0x72, 0x0072, # LATIN SMALL LETTER R
133
+ 0x73, 0x0073, # LATIN SMALL LETTER S
134
+ 0x74, 0x0074, # LATIN SMALL LETTER T
135
+ 0x75, 0x0075, # LATIN SMALL LETTER U
136
+ 0x76, 0x0076, # LATIN SMALL LETTER V
137
+ 0x77, 0x0077, # LATIN SMALL LETTER W
138
+ 0x78, 0x0078, # LATIN SMALL LETTER X
139
+ 0x79, 0x0079, # LATIN SMALL LETTER Y
140
+ 0x7A, 0x007A, # LATIN SMALL LETTER Z
141
+ 0x7B, 0x00E4, # LATIN SMALL LETTER A WITH DIAERESIS
142
+ 0x7C, 0x00F6, # LATIN SMALL LETTER O WITH DIAERESIS
143
+ 0x7D, 0x00F1, # LATIN SMALL LETTER N WITH TILDE
144
+ 0x7E, 0x00FC, # LATIN SMALL LETTER U WITH DIAERESIS
145
+ 0x7F, 0x00E0, # LATIN SMALL LETTER A WITH GRAVE
146
+ ]
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gsm_tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Ang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-09 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70344682777260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70344682777260
25
+ - !ruby/object:Gem::Dependency
26
+ name: guard-rspec
27
+ requirement: &70344682781580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70344682781580
36
+ description: Adds various methods to check GSM 03.38 character encoding compatibility.
37
+ email:
38
+ - andukz@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - .rvmrc
45
+ - Gemfile
46
+ - Guardfile
47
+ - Rakefile
48
+ - gsm_tools.gemspec
49
+ - lib/gsm_tools.rb
50
+ - lib/gsm_tools/base.rb
51
+ - lib/gsm_tools/string.rb
52
+ - lib/gsm_tools/version.rb
53
+ - spec/lib/gsm_tools/base_spec.rb
54
+ - spec/lib/gsm_tools/string_spec.rb
55
+ - spec/lib/gsm_tools_spec.rb
56
+ - spec/spec_helper.rb
57
+ homepage: ''
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ segments:
70
+ - 0
71
+ hash: -1888712993988250446
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
79
+ - 0
80
+ hash: -1888712993988250446
81
+ requirements: []
82
+ rubyforge_project: gsm_tools
83
+ rubygems_version: 1.8.10
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: GSM 03.38 extension libraries
87
+ test_files:
88
+ - spec/lib/gsm_tools/base_spec.rb
89
+ - spec/lib/gsm_tools/string_spec.rb
90
+ - spec/lib/gsm_tools_spec.rb
91
+ - spec/spec_helper.rb