smspromote 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ Create a new ruby source file with the following script
18
18
 
19
19
  msg = SmsPromote::Message.new('001231231231', 'Hello World')
20
20
 
21
- GATEWAY.send_messsage(msg)
21
+ GATEWAY.send_message(msg)
22
22
 
23
23
  p msg.delivered?
24
24
  p msg.cost
@@ -1,5 +1,5 @@
1
1
  module SmsPromote
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
5
5
  gem 'rest-client', '>= 1.6.0'
@@ -8,3 +8,4 @@ require 'rest_client'
8
8
 
9
9
  require 'smspromote/message'
10
10
  require 'smspromote/gateway'
11
+ require 'smspromote/encoding'
@@ -1,309 +1,178 @@
1
- module Encoding
2
- GSM_UNICODE = [
3
- 0x0040, # 0x00 COMMERCIAL AT
4
- 0x00A3, # 0x01 POUND SIGN
5
- 0x0024, # 0x02 DOLLAR SIGN
6
- 0x00A5, # 0x03 YEN SIGN
7
- 0x00E8, # 0x04 LATIN SMALL LETTER E WITH GRAVE
8
- 0x00E9, # 0x05 LATIN SMALL LETTER E WITH ACUTE
9
- 0x00F9, # 0x06 LATIN SMALL LETTER U WITH GRAVE
10
- 0x00EC, # 0x07 LATIN SMALL LETTER I WITH GRAVE
11
- 0x00F2, # 0x08 LATIN SMALL LETTER O WITH GRAVE
12
- 0x00E7, # 0x09 LATIN SMALL LETTER C WITH CEDILLA
13
- 0x000A, # 0x0A LINE FEED
14
- 0x00D8, # 0x0B LATIN CAPITAL LETTER O WITH STROKE
15
- 0x00F8, # 0x0C LATIN SMALL LETTER O WITH STROKE
16
- 0x000D, # 0x0D CARRIAGE RETURN
17
- 0x00C5, # 0x0E LATIN CAPITAL LETTER A WITH RING ABOVE
18
- 0x00E5, # 0x0F LATIN SMALL LETTER A WITH RING ABOVE
19
- 0x0394, # 0x10 GREEK CAPITAL LETTER DELTA
20
- 0x005F, # 0x11 LOW LINE
21
- 0x03A6, # 0x12 GREEK CAPITAL LETTER PHI
22
- 0x0393, # 0x13 GREEK CAPITAL LETTER GAMMA
23
- 0x039B, # 0x14 GREEK CAPITAL LETTER LAMDA
24
- 0x03A9, # 0x15 GREEK CAPITAL LETTER OMEGA
25
- 0x03A0, # 0x16 GREEK CAPITAL LETTER PI
26
- 0x03A8, # 0x17 GREEK CAPITAL LETTER PSI
27
- 0x03A3, # 0x18 GREEK CAPITAL LETTER SIGMA
28
- 0x0398, # 0x19 GREEK CAPITAL LETTER THETA
29
- 0x039E, # 0x1A GREEK CAPITAL LETTER XI
30
- 0x00A0, # 0x1B ESCAPE TO EXTENSION TABLE
31
- 0x00C6, # 0x1C LATIN CAPITAL LETTER AE
32
- 0x00E6, # 0x1D LATIN SMALL LETTER AE
33
- 0x00DF, # 0x1E LATIN SMALL LETTER SHARP S (German)
34
- 0x00C9, # 0x1F LATIN CAPITAL LETTER E WITH ACUTE
35
- 0x0020, # 0x20 SPACE
36
- 0x0021, # 0x21 EXCLAMATION MARK
37
- 0x0022, # 0x22 QUOTATION MARK
38
- 0x0023, # 0x23 NUMBER SIGN
39
- 0x00A4, # 0x24 CURRENCY SIGN
40
- 0x0025, # 0x25 PERCENT SIGN
41
- 0x0026, # 0x26 AMPERSAND
42
- 0x0027, # 0x27 APOSTROPHE
43
- 0x0028, # 0x28 LEFT PARENTHESIS
44
- 0x0029, # 0x29 RIGHT PARENTHESIS
45
- 0x002A, # 0x2A ASTERISK
46
- 0x002B, # 0x2B PLUS SIGN
47
- 0x002C, # 0x2C COMMA
48
- 0x002D, # 0x2D HYPHEN-MINUS
49
- 0x002E, # 0x2E FULL STOP
50
- 0x002F, # 0x2F SOLIDUS
51
- 0x0030, # 0x30 DIGIT ZERO
52
- 0x0031, # 0x31 DIGIT ONE
53
- 0x0032, # 0x32 DIGIT TWO
54
- 0x0033, # 0x33 DIGIT THREE
55
- 0x0034, # 0x34 DIGIT FOUR
56
- 0x0035, # 0x35 DIGIT FIVE
57
- 0x0036, # 0x36 DIGIT SIX
58
- 0x0037, # 0x37 DIGIT SEVEN
59
- 0x0038, # 0x38 DIGIT EIGHT
60
- 0x0039, # 0x39 DIGIT NINE
61
- 0x003A, # 0x3A COLON
62
- 0x003B, # 0x3B SEMICOLON
63
- 0x003C, # 0x3C LESS-THAN SIGN
64
- 0x003D, # 0x3D EQUALS SIGN
65
- 0x003E, # 0x3E GREATER-THAN SIGN
66
- 0x003F, # 0x3F QUESTION MARK
67
- 0x00A1, # 0x40 INVERTED EXCLAMATION MARK
68
- 0x0041, # 0x41 LATIN CAPITAL LETTER A
69
- 0x0042, # 0x42 LATIN CAPITAL LETTER B
70
- 0x0043, # 0x43 LATIN CAPITAL LETTER C
71
- 0x0044, # 0x44 LATIN CAPITAL LETTER D
72
- 0x0045, # 0x45 LATIN CAPITAL LETTER E
73
- 0x0046, # 0x46 LATIN CAPITAL LETTER F
74
- 0x0047, # 0x47 LATIN CAPITAL LETTER G
75
- 0x0048, # 0x48 LATIN CAPITAL LETTER H
76
- 0x0049, # 0x49 LATIN CAPITAL LETTER I
77
- 0x004A, # 0x4A LATIN CAPITAL LETTER J
78
- 0x004B, # 0x4B LATIN CAPITAL LETTER K
79
- 0x004C, # 0x4C LATIN CAPITAL LETTER L
80
- 0x004D, # 0x4D LATIN CAPITAL LETTER M
81
- 0x004E, # 0x4E LATIN CAPITAL LETTER N
82
- 0x004F, # 0x4F LATIN CAPITAL LETTER O
83
- 0x0050, # 0x50 LATIN CAPITAL LETTER P
84
- 0x0051, # 0x51 LATIN CAPITAL LETTER Q
85
- 0x0052, # 0x52 LATIN CAPITAL LETTER R
86
- 0x0053, # 0x53 LATIN CAPITAL LETTER S
87
- 0x0054, # 0x54 LATIN CAPITAL LETTER T
88
- 0x0055, # 0x55 LATIN CAPITAL LETTER U
89
- 0x0056, # 0x56 LATIN CAPITAL LETTER V
90
- 0x0057, # 0x57 LATIN CAPITAL LETTER W
91
- 0x0058, # 0x58 LATIN CAPITAL LETTER X
92
- 0x0059, # 0x59 LATIN CAPITAL LETTER Y
93
- 0x005A, # 0x5A LATIN CAPITAL LETTER Z
94
- 0x00C4, # 0x5B LATIN CAPITAL LETTER A WITH DIAERESIS
95
- 0x00D6, # 0x5C LATIN CAPITAL LETTER O WITH DIAERESIS
96
- 0x00D1, # 0x5D LATIN CAPITAL LETTER N WITH TILDE
97
- 0x00DC, # 0x5E LATIN CAPITAL LETTER U WITH DIAERESIS
98
- 0x00A7, # 0x5F SECTION SIGN
99
- 0x00BF, # 0x60 INVERTED QUESTION MARK
100
- 0x0061, # 0x61 LATIN SMALL LETTER A
101
- 0x0062, # 0x62 LATIN SMALL LETTER B
102
- 0x0063, # 0x63 LATIN SMALL LETTER C
103
- 0x0064, # 0x64 LATIN SMALL LETTER D
104
- 0x0065, # 0x65 LATIN SMALL LETTER E
105
- 0x0066, # 0x66 LATIN SMALL LETTER F
106
- 0x0067, # 0x67 LATIN SMALL LETTER G
107
- 0x0068, # 0x68 LATIN SMALL LETTER H
108
- 0x0069, # 0x69 LATIN SMALL LETTER I
109
- 0x006A, # 0x6A LATIN SMALL LETTER J
110
- 0x006B, # 0x6B LATIN SMALL LETTER K
111
- 0x006C, # 0x6C LATIN SMALL LETTER L
112
- 0x006D, # 0x6D LATIN SMALL LETTER M
113
- 0x006E, # 0x6E LATIN SMALL LETTER N
114
- 0x006F, # 0x6F LATIN SMALL LETTER O
115
- 0x0070, # 0x70 LATIN SMALL LETTER P
116
- 0x0071, # 0x71 LATIN SMALL LETTER Q
117
- 0x0072, # 0x72 LATIN SMALL LETTER R
118
- 0x0073, # 0x73 LATIN SMALL LETTER S
119
- 0x0074, # 0x74 LATIN SMALL LETTER T
120
- 0x0075, # 0x75 LATIN SMALL LETTER U
121
- 0x0076, # 0x76 LATIN SMALL LETTER V
122
- 0x0077, # 0x77 LATIN SMALL LETTER W
123
- 0x0078, # 0x78 LATIN SMALL LETTER X
124
- 0x0079, # 0x79 LATIN SMALL LETTER Y
125
- 0x007A, # 0x7A LATIN SMALL LETTER Z
126
- 0x00E4, # 0x7B LATIN SMALL LETTER A WITH DIAERESIS
127
- 0x00F6, # 0x7C LATIN SMALL LETTER O WITH DIAERESIS
128
- 0x00F1, # 0x7D LATIN SMALL LETTER N WITH TILDE
129
- 0x00FC, # 0x7E LATIN SMALL LETTER U WITH DIAERESIS
130
- 0x00E0 # 0x7F LATIN SMALL LETTER A WITH GRAVE
131
- ]
1
+ module SmsPromote
2
+ module Encoding
3
+ # UTF-8 2 GSM-7 TABLE
4
+ UNICODE2GSM = {
5
+ 0x0040 => "\x00", # COMMERCIAL AT
6
+ 0x00A3 => "\x01", # POUND SIGN
7
+ 0x0024 => "\x02", # DOLLAR SIGN
8
+ 0x00A5 => "\x03", # YEN SIGN
9
+ 0x00E8 => "\x04", # LATIN SMALL LETTER E WITH GRAVE
10
+ 0x00E9 => "\x05", # LATIN SMALL LETTER E WITH ACUTE
11
+ 0x00F9 => "\x06", # LATIN SMALL LETTER U WITH GRAVE
12
+ 0x00EC => "\x07", # LATIN SMALL LETTER I WITH GRAVE
13
+ 0x00F2 => "\x08", # LATIN SMALL LETTER O WITH GRAVE
14
+ 0x00E7 => "\x09", # LATIN SMALL LETTER C WITH CEDILLA
15
+ 0x000A => "\x0A", # LINE FEED
16
+ 0x00D8 => "\x0B", # LATIN CAPITAL LETTER O WITH STROKE
17
+ 0x00F8 => "\x0C", # LATIN SMALL LETTER O WITH STROKE
18
+ 0x000D => "\x0D", # CARRIAGE RETURN
19
+ 0x00C5 => "\x0E", # LATIN CAPITAL LETTER A WITH RING ABOVE
20
+ 0x00E5 => "\x0F", # LATIN SMALL LETTER A WITH RING ABOVE
21
+ 0x0394 => "\x10", # GREEK CAPITAL LETTER DELTA
22
+ 0x005F => "\x11", # LOW LINE
23
+ 0x03A6 => "\x12", # GREEK CAPITAL LETTER PHI
24
+ 0x0393 => "\x13", # GREEK CAPITAL LETTER GAMMA
25
+ 0x039B => "\x14", # GREEK CAPITAL LETTER LAMDA
26
+ 0x03A9 => "\x15", # GREEK CAPITAL LETTER OMEGA
27
+ 0x03A0 => "\x16", # GREEK CAPITAL LETTER PI
28
+ 0x03A8 => "\x17", # GREEK CAPITAL LETTER PSI
29
+ 0x03A3 => "\x18", # GREEK CAPITAL LETTER SIGMA
30
+ 0x0398 => "\x19", # GREEK CAPITAL LETTER THETA
31
+ 0x039E => "\x1A", # GREEK CAPITAL LETTER XI
32
+ 0x00A0 => "\x1B", # ESCAPE TO EXTENSION TABLE
33
+ 0x00C6 => "\x1C", # LATIN CAPITAL LETTER AE
34
+ 0x00E6 => "\x1D", # LATIN SMALL LETTER AE
35
+ 0x00DF => "\x1E", # LATIN SMALL LETTER SHARP S (German)
36
+ 0x00C9 => "\x1F", # LATIN CAPITAL LETTER E WITH ACUTE
37
+ 0x0020 => "\x20", # SPACE
38
+ 0x0021 => "\x21", # EXCLAMATION MARK
39
+ 0x0022 => "\x22", # QUOTATION MARK
40
+ 0x0023 => "\x23", # NUMBER SIGN
41
+ 0x00A4 => "\x24", # CURRENCY SIGN
42
+ 0x0025 => "\x25", # PERCENT SIGN
43
+ 0x0026 => "\x26", # AMPERSAND
44
+ 0x0027 => "\x27", # APOSTROPHE
45
+ 0x0028 => "\x28", # LEFT PARENTHESIS
46
+ 0x0029 => "\x29", # RIGHT PARENTHESIS
47
+ 0x002A => "\x2A", # ASTERISK
48
+ 0x002B => "\x2B", # PLUS SIGN
49
+ 0x002C => "\x2C", # COMMA
50
+ 0x002D => "\x2D", # HYPHEN-MINUS
51
+ 0x002E => "\x2E", # FULL STOP
52
+ 0x002F => "\x2F", # SOLIDUS
53
+ 0x0030 => "\x30", # DIGIT ZERO
54
+ 0x0031 => "\x31", # DIGIT ONE
55
+ 0x0032 => "\x32", # DIGIT TWO
56
+ 0x0033 => "\x33", # DIGIT THREE
57
+ 0x0034 => "\x34", # DIGIT FOUR
58
+ 0x0035 => "\x35", # DIGIT FIVE
59
+ 0x0036 => "\x36", # DIGIT SIX
60
+ 0x0037 => "\x37", # DIGIT SEVEN
61
+ 0x0038 => "\x38", # DIGIT EIGHT
62
+ 0x0039 => "\x39", # DIGIT NINE
63
+ 0x003A => "\x3A", # COLON
64
+ 0x003B => "\x3B", # SEMICOLON
65
+ 0x003C => "\x3C", # LESS-THAN SIGN
66
+ 0x003D => "\x3D", # EQUALS SIGN
67
+ 0x003E => "\x3E", # GREATER-THAN SIGN
68
+ 0x003F => "\x3F", # QUESTION MARK
69
+ 0x00A1 => "\x40", # INVERTED EXCLAMATION MARK
70
+ 0x0041 => "\x41", # LATIN CAPITAL LETTER A
71
+ 0x0042 => "\x42", # LATIN CAPITAL LETTER B
72
+ 0x0043 => "\x43", # LATIN CAPITAL LETTER C
73
+ 0x0044 => "\x44", # LATIN CAPITAL LETTER D
74
+ 0x0045 => "\x45", # LATIN CAPITAL LETTER E
75
+ 0x0046 => "\x46", # LATIN CAPITAL LETTER F
76
+ 0x0047 => "\x47", # LATIN CAPITAL LETTER G
77
+ 0x0048 => "\x48", # LATIN CAPITAL LETTER H
78
+ 0x0049 => "\x49", # LATIN CAPITAL LETTER I
79
+ 0x004A => "\x4A", # LATIN CAPITAL LETTER J
80
+ 0x004B => "\x4B", # LATIN CAPITAL LETTER K
81
+ 0x004C => "\x4C", # LATIN CAPITAL LETTER L
82
+ 0x004D => "\x4D", # LATIN CAPITAL LETTER M
83
+ 0x004E => "\x4E", # LATIN CAPITAL LETTER N
84
+ 0x004F => "\x4F", # LATIN CAPITAL LETTER O
85
+ 0x0050 => "\x50", # LATIN CAPITAL LETTER P
86
+ 0x0051 => "\x51", # LATIN CAPITAL LETTER Q
87
+ 0x0052 => "\x52", # LATIN CAPITAL LETTER R
88
+ 0x0053 => "\x53", # LATIN CAPITAL LETTER S
89
+ 0x0054 => "\x54", # LATIN CAPITAL LETTER T
90
+ 0x0055 => "\x55", # LATIN CAPITAL LETTER U
91
+ 0x0056 => "\x56", # LATIN CAPITAL LETTER V
92
+ 0x0057 => "\x57", # LATIN CAPITAL LETTER W
93
+ 0x0058 => "\x58", # LATIN CAPITAL LETTER X
94
+ 0x0059 => "\x59", # LATIN CAPITAL LETTER Y
95
+ 0x005A => "\x5A", # LATIN CAPITAL LETTER Z
96
+ 0x00C4 => "\x5B", # LATIN CAPITAL LETTER A WITH DIAERESIS
97
+ 0x00D6 => "\x5C", # LATIN CAPITAL LETTER O WITH DIAERESIS
98
+ 0x00D1 => "\x5D", # LATIN CAPITAL LETTER N WITH TILDE
99
+ 0x00DC => "\x5E", # LATIN CAPITAL LETTER U WITH DIAERESIS
100
+ 0x00A7 => "\x5F", # SECTION SIGN
101
+ 0x00BF => "\x60", # INVERTED QUESTION MARK
102
+ 0x0061 => "\x61", # LATIN SMALL LETTER A
103
+ 0x0062 => "\x62", # LATIN SMALL LETTER B
104
+ 0x0063 => "\x63", # LATIN SMALL LETTER C
105
+ 0x0064 => "\x64", # LATIN SMALL LETTER D
106
+ 0x0065 => "\x65", # LATIN SMALL LETTER E
107
+ 0x0066 => "\x66", # LATIN SMALL LETTER F
108
+ 0x0067 => "\x67", # LATIN SMALL LETTER G
109
+ 0x0068 => "\x68", # LATIN SMALL LETTER H
110
+ 0x0069 => "\x69", # LATIN SMALL LETTER I
111
+ 0x006A => "\x6A", # LATIN SMALL LETTER J
112
+ 0x006B => "\x6B", # LATIN SMALL LETTER K
113
+ 0x006C => "\x6C", # LATIN SMALL LETTER L
114
+ 0x006D => "\x6D", # LATIN SMALL LETTER M
115
+ 0x006E => "\x6E", # LATIN SMALL LETTER N
116
+ 0x006F => "\x6F", # LATIN SMALL LETTER O
117
+ 0x0070 => "\x70", # LATIN SMALL LETTER P
118
+ 0x0071 => "\x71", # LATIN SMALL LETTER Q
119
+ 0x0072 => "\x72", # LATIN SMALL LETTER R
120
+ 0x0073 => "\x73", # LATIN SMALL LETTER S
121
+ 0x0074 => "\x74", # LATIN SMALL LETTER T
122
+ 0x0075 => "\x75", # LATIN SMALL LETTER U
123
+ 0x0076 => "\x76", # LATIN SMALL LETTER V
124
+ 0x0077 => "\x77", # LATIN SMALL LETTER W
125
+ 0x0078 => "\x78", # LATIN SMALL LETTER X
126
+ 0x0079 => "\x79", # LATIN SMALL LETTER Y
127
+ 0x007A => "\x7A", # LATIN SMALL LETTER Z
128
+ 0x00E4 => "\x7B", # LATIN SMALL LETTER A WITH DIAERESIS
129
+ 0x00F6 => "\x7C", # LATIN SMALL LETTER O WITH DIAERESIS
130
+ 0x00F1 => "\x7D", # LATIN SMALL LETTER N WITH TILDE
131
+ 0x00FC => "\x7E", # LATIN SMALL LETTER U WITH DIAERESIS
132
+ 0x00E0 => "\x7F", # LATIN SMALL LETTER A WITH GRAVE
133
+ ############## ESCAPES ###############
134
+ 0x000C => "\x1B\x0A", # FORM FEED
135
+ 0x005E => "\x1B\x14", # CIRCUMFLEX ACCENT
136
+ 0x007B => "\x1B\x28", # LEFT CURLY BRACKET
137
+ 0x007D => "\x1B\x29", # RIGHT CURLY BRACKET
138
+ 0x005C => "\x1B\x2F", # REVERSE SOLIDUS
139
+ 0x005B => "\x1B\x3C", # LEFT SQUARE BRACKET
140
+ 0x007E => "\x1B\x3D", # TILDE
141
+ 0x005D => "\x1B\x3E", # RIGHT SQUARE BRACKET
142
+ 0x007C => "\x1B\x40", # VERTICAL LINE
143
+ 0x20AC => "\x1B\x65" # EURO SIGN
144
+ }
145
+
146
+ # GSM-7 2 UTF-8 TABLE
147
+ GSM2UNICODE = {}
148
+ for key, value in UNICODE2GSM do
149
+ GSM2UNICODE[value] = key
150
+ end
132
151
 
133
- GSM_ESCAPES = [
134
- { :from => 0x0A, :to => 0x000C }, /* FORM FEED
135
- { :from => 0x14, :to => 0x005E }, /* CIRCUMFLEX ACCENT
136
- { :from => 0x28, :to => 0x007B }, /* LEFT CURLY BRACKET
137
- { :from => 0x29, :to => 0x007D }, /* RIGHT CURLY BRACKET
138
- { :from => 0x2F, :to => 0x005C }, /* REVERSE SOLIDUS
139
- { :from => 0x3C, :to => 0x005B }, /* LEFT SQUARE BRACKET
140
- { :from => 0x3D, :to => 0x007E }, /* TILDE
141
- { :from => 0x3E, :to => 0x005D }, /* RIGHT SQUARE BRACKET
142
- { :from => 0x40, :to => 0x007C }, /* VERTICAL LINE
143
- { :from => 0x65, :to => 0x20AC }, /* EURO SIGN
144
- { :from => 0 , :to => 0 }
145
- ]
152
+ # returns string (str) GSM-7 encoded
153
+ def self.to_gsm(str)
154
+ new_str = ""
155
+ str.unpack("U*").each do |char|
156
+ new_str << UNICODE2GSM[char]
157
+ end
158
+ new_str
159
+ end
146
160
 
161
+ # returns string (str) UTF-8 encoded
162
+ def self.from_gsm(str)
163
+ new_str = ""
164
+ escape = false
165
+ str.each_char do |char|
166
+ if char == "\e"
167
+ escape = true
168
+ elsif escape
169
+ escape = false
170
+ new_str << [GSM2UNICODE["\e" + char]].pack("U")
171
+ else
172
+ new_str << [GSM2UNICODE[char]].pack("U")
173
+ end
174
+ end
175
+ new_str
176
+ end
177
+ end
147
178
  end
148
-
149
-
150
- static int
151
- gsm7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
152
- {
153
- int i = 0;
154
- if( *s > 0x7f )
155
- return RET_ILSEQ;
156
- else if( *s == 0x1B ) {
157
- if( n >= 2 ) {
158
- while( gsmEscapes[ i ].from ) {
159
- if( gsmEscapes[ i ].from == s[1] ) {
160
- *pwc = gsmEscapes[ i ].to;
161
- return 2;
162
- }
163
- i++;
164
- }
165
- return RET_ILSEQ;
166
- } else
167
- return RET_TOOFEW( 1 );
168
- }
169
- *pwc = gsmToUnicode[ *s ];
170
- return 1;
171
- }
172
- static int
173
- gsm7_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
174
- {
175
- unsigned char s1, s2;
176
- s1 = (wc & 0xff00) >> 8;
177
- s2 = wc & 0x00ff;
178
- if( s1 == 0x00 ) {
179
- if( s2 == 0xA || s2 == 0xD ||
180
- (s2 >= 0x20 && s2 <= 0x23 ) || (s2 >= 0x25 && s2 <= 0x3f)
181
- || (s2 >= 0x41 && s2 <= 0x5A) || (s2 >= 0x61 && s2 <= 0x7A) ) {
182
- *r = s2;
183
- return 1;
184
- } else {
185
- switch( s2 ) {
186
- case 0x24: *r = 0x02; return 1;
187
- case 0x40: *r = 0x00; return 1;
188
- case 0x5b: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x3c; return 2; }
189
- else return RET_TOOSMALL;
190
- case 0x5c: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x2f; return 2; }
191
- else return RET_TOOSMALL;
192
- case 0x5d: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x3e; return 2; }
193
- else return RET_TOOSMALL;
194
- case 0x5e: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x14; return 2; }
195
- else return RET_TOOSMALL;
196
- case 0x5f: *r = 0x11; return 1;
197
- case 0x7b: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x28; return 2; }
198
- else return RET_TOOSMALL;
199
- case 0x7c: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x40; return 2; }
200
- else return RET_TOOSMALL;
201
- case 0x7d: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x29; return 2; }
202
- else return RET_TOOSMALL;
203
- case 0x7e: if( n >= 2 ) {r[0] = 0x1b; r[1] = 0x3d; return 2; }
204
- else return RET_TOOSMALL;
205
- case 0xa3: *r = 0x01; return 1;
206
- case 0xa4: *r = 0x24; return 1;
207
- case 0xa5: *r = 0x03; return 1;
208
- case 0xa7: *r = 0x5f; return 1;
209
- case 0xb0: *r = 0x24; return 1;
210
- case 0xbf: *r = 0x60; return 1;
211
- case 0xc5: *r = 0x0e; return 1;
212
- case 0xc6: *r = 0x1c; return 1;
213
- case 0xc7: *r = 0x09; return 1;
214
- case 0xc9: *r = 0x1f; return 1;
215
- case 0xc4: *r = 0x5b; return 1;
216
- case 0xd1: *r = 0x5d; return 1;
217
- case 0xd6: *r = 0x5c; return 1;
218
- case 0xd8: *r = 0x0b; return 1;
219
- case 0xdc: *r = 0x5e; return 1;
220
- case 0xdf: *r = 0x1e; return 1;
221
- case 0xe0: *r = 0x7f; return 1;
222
- case 0xe4: *r = 0x7b; return 1;
223
- case 0xe5: *r = 0x0f; return 1;
224
- case 0xe6: *r = 0x1d; return 1;
225
- case 0xe7: *r = 0x09; return 1;
226
- case 0xe8: *r = 0x04; return 1;
227
- case 0xe9: *r = 0x05; return 1;
228
- case 0xec: *r = 0x07; return 1;
229
- case 0xf1: *r = 0x7d; return 1;
230
- case 0xf2: *r = 0x08; return 1;
231
- case 0xf6: *r = 0x7c; return 1;
232
- case 0xf8: *r = 0x0c; return 1;
233
- case 0xf9: *r = 0x06; return 1;
234
- case 0xfc: *r = 0x7e; return 1;
235
- /* one way mappings
236
- case 0xc0: *r = 0x41; return 1;
237
- case 0xc1: *r = 0x41; return 1;
238
- case 0xc2: *r = 0x41; return 1;
239
- case 0xc3: *r = 0x41; return 1;
240
- case 0xc8: *r = 0x45; return 1;
241
- case 0xca: *r = 0x45; return 1;
242
- case 0xcb: *r = 0x45; return 1;
243
- case 0xcc: *r = 0x49; return 1;
244
- case 0xcd: *r = 0x49; return 1;
245
- case 0xce: *r = 0x49; return 1;
246
- case 0xcf: *r = 0x49; return 1;
247
- case 0xd2: *r = 0x4f; return 1;
248
- case 0xd3: *r = 0x4f; return 1;
249
- case 0xd4: *r = 0x4f; return 1;
250
- case 0xd5: *r = 0x4f; return 1;
251
- case 0xd9: *r = 0x55; return 1;
252
- case 0xda: *r = 0x55; return 1;
253
- case 0xdb: *r = 0x55; return 1;
254
- case 0xdd: *r = 0x59; return 1;
255
- case 0xe1: *r = 0x61; return 1;
256
- case 0xe2: *r = 0x61; return 1;
257
- case 0xe3: *r = 0x61; return 1;
258
- case 0xea: *r = 0x65; return 1;
259
- case 0xeb: *r = 0x65; return 1;
260
- case 0xed: *r = 0x69; return 1;
261
- case 0xee: *r = 0x69; return 1;
262
- case 0xef: *r = 0x69; return 1;
263
- case 0xf3: *r = 0x6f; return 1;
264
- case 0xf4: *r = 0x6f; return 1;
265
- case 0xf5: *r = 0x6f; return 1;
266
- case 0xfa: *r = 0x75; return 1;
267
- case 0xfb: *r = 0x75; return 1;
268
- case 0xfd: *r = 0x79; return 1;
269
- case 0xff: *r = 0x79; return 1;
270
- }
271
- }
272
- return RET_ILUNI;
273
- } else if( s1 == 0x20 ) {
274
- if( s2 == 0xac ) {
275
- if( n >= 2 ) {
276
- r[0] = 0x1b; r[1] = 0x65; return 2;
277
- } else return RET_TOOSMALL;
278
- }
279
- } else if( s1 = 0x03 ) {
280
- switch( s2 ) {
281
- case 0x94: *r = 0x10; return 1;
282
- case 0xa6: *r = 0x12; return 1;
283
- case 0x93: *r = 0x13; return 1;
284
- case 0x9b: *r = 0x14; return 1;
285
- case 0xa9: *r = 0x15; return 1;
286
- case 0xa0: *r = 0x16; return 1;
287
- case 0xa8: *r = 0x17; return 1;
288
- case 0xa3: *r = 0x18; return 1;
289
- case 0x98: *r = 0x19; return 1;
290
- case 0x9e: *r = 0x1a; return 1;
291
- case 0x91: *r = 0x41; return 1;
292
- case 0x92: *r = 0x42; return 1;
293
- case 0x95: *r = 0x45; return 1;
294
- case 0x97: *r = 0x48; return 1;
295
- case 0x99: *r = 0x49; return 1;
296
- case 0x9a: *r = 0x4b; return 1;
297
- case 0x9c: *r = 0x4d; return 1;
298
- case 0x9d: *r = 0x4e; return 1;
299
- case 0x9f: *r = 0x4f; return 1;
300
- case 0xa1: *r = 0x50; return 1;
301
- case 0xa4: *r = 0x54; return 1;
302
- case 0xa5: *r = 0x55; return 1;
303
- case 0xa7: *r = 0x58; return 1;
304
- case 0x96: *r = 0x5a; return 1;
305
- }
306
- return RET_ILUNI;
307
- }
308
- return RET_ILUNI;
309
- }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smspromote
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vincent Landgraf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-24 00:00:00 +02:00
18
+ date: 2010-07-26 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency