gsm_encoder 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/gsm_encoder.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f714afc19eab777646d3901fd555673bd35f2fc
|
4
|
+
data.tar.gz: 34bdd8548d11be5ce085e6a6f933a27eea311b7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaefbcb9d51481a45945bd9a813d69afa702b69eb5b1133098345e91df692f05d3cfd69215b85d485fd8780e9983c65d31d2ac436a0004e6ab0ad01a3fefe0c9
|
7
|
+
data.tar.gz: e54b37b0edb6abf06cd6c725c4bba5bce500b07d9b6cdb878d50fdaca01ead3b3d3884a20f8ed66a31c820569a0fc435afa9b462178660ec1e6ee929500c415f
|
data/README.md
CHANGED
data/lib/gsm_encoder.rb
CHANGED
@@ -55,13 +55,13 @@ module GSMEncoder
|
|
55
55
|
# @param str The String to verfiy
|
56
56
|
# @return True if the charset can represent every character in the Ruby
|
57
57
|
# String, otherwise false.
|
58
|
-
def can_encode?
|
58
|
+
def can_encode?(str)
|
59
59
|
return true if !str
|
60
60
|
|
61
61
|
str.each_char do |c|
|
62
62
|
# simple range checks for most common characters (' '..'_') or ('a'..'~')
|
63
63
|
b = c.getbyte(0)
|
64
|
-
unless b >= 0x20 && b <= 0x5F || b >= 0x61 && b <= 0x7E || CHARS.
|
64
|
+
unless b >= 0x20 && b <= 0x5F || b >= 0x61 && b <= 0x7E || CHARS.include?(c)
|
65
65
|
return false
|
66
66
|
end
|
67
67
|
end
|
@@ -77,10 +77,10 @@ module GSMEncoder
|
|
77
77
|
|
78
78
|
begin
|
79
79
|
str.each_char do |c|
|
80
|
-
if index =
|
81
|
-
buffer << EXTENDED_ESCAPE
|
80
|
+
if index = CHAR_TABLE.rindex(c)
|
82
81
|
buffer << index
|
83
|
-
elsif index =
|
82
|
+
elsif index = EXT_CHAR_TABLE.index(c)
|
83
|
+
buffer << EXTENDED_ESCAPE
|
84
84
|
buffer << index
|
85
85
|
else
|
86
86
|
buffer << replace_char
|