scon 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scon.rb +2 -2
- data/lib/scon/generator.rb +2 -2
- data/lib/scon/parser.rb +4 -4
- data/lib/scon/version.rb +1 -1
- 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: 442e89803ca4cb396738c8c85eb6df9e5fe88e90
|
4
|
+
data.tar.gz: 630d42f52459ea20390177eb70e0d5c40f62cdf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bce748a277d73d7baf69714183320acf431d733481fa1be8f04ad4cad335dd50a31e86b7382eeaeeec5401c99aa9981101024d8ef4a5cf7278273bcc536804a
|
7
|
+
data.tar.gz: 7274b3cca619869575a57113adb768c712eb3ab016f328c48a5564b70b6b5d7c0befb4dfd05786d6d939b2c69de522b7189dd47460efe709bf52fb9ebcd23d5d
|
data/lib/scon.rb
CHANGED
@@ -28,12 +28,12 @@ module SCON
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.string_bytes str
|
31
|
-
bytes = str.bytes
|
31
|
+
bytes = str.encode("utf-8").bytes
|
32
32
|
instr = 0xD0
|
33
33
|
if bytes.length < 32
|
34
34
|
instr += bytes.length
|
35
35
|
else
|
36
|
-
bytes <<
|
36
|
+
bytes << 0xFF
|
37
37
|
end
|
38
38
|
[instr, bytes]
|
39
39
|
end
|
data/lib/scon/generator.rb
CHANGED
@@ -161,10 +161,10 @@ private
|
|
161
161
|
returnval = []
|
162
162
|
if value <= 0x99 && value >= 0 # Byte, no following data bytes
|
163
163
|
returnval[0] = value
|
164
|
-
elsif value <= ((2**16)/2-1) && value >= -(((2**16)/2
|
164
|
+
elsif value <= ((2**16)/2-1) && value >= -(((2**16)/2+1)) # Short, following bytes
|
165
165
|
returnval[0] = Constants::DATA[:short]
|
166
166
|
returnval[1] = Conversions.short_bytes(value)
|
167
|
-
elsif value <= ((2**32)/2-1) && value >= -(((2**32)/2
|
167
|
+
elsif value <= ((2**32)/2-1) && value >= -(((2**32)/2+1)) # Integer, following bytes
|
168
168
|
returnval[0] = Constants::DATA[:integer]
|
169
169
|
returnval[1] = Conversions.int_bytes(value)
|
170
170
|
else # Long, following bytes
|
data/lib/scon/parser.rb
CHANGED
@@ -32,10 +32,10 @@ private
|
|
32
32
|
elsif data[0] == 0xD0
|
33
33
|
data.shift
|
34
34
|
str = []
|
35
|
-
while (tmp = data.shift) !=
|
35
|
+
while (tmp = data.shift) != 0xFF
|
36
36
|
str << tmp
|
37
37
|
end
|
38
|
-
return str.pack("c*")
|
38
|
+
return str.pack("c*").force_encoding("utf-8")
|
39
39
|
else
|
40
40
|
return false
|
41
41
|
end
|
@@ -46,10 +46,10 @@ private
|
|
46
46
|
return @data.shift(instruct - 0xD0).pack("c*")
|
47
47
|
elsif instruct == 0xD0
|
48
48
|
str = []
|
49
|
-
while (tmp = @data.shift) !=
|
49
|
+
while (tmp = @data.shift) != 0xFF
|
50
50
|
str << tmp
|
51
51
|
end
|
52
|
-
return str.pack("c*")
|
52
|
+
return str.pack("c*").force_encoding("utf-8")
|
53
53
|
else
|
54
54
|
return false
|
55
55
|
end
|
data/lib/scon/version.rb
CHANGED