10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/baykit/bayserver/util/url_decoder.rb', line 10
def self.parse_special(str, enc)
arr = ByteArray.new
index = 0
while(index < str.length)
c = str[index]
case c
when '+'
arr.put_bytes(c)
index = index + 1
when '%'
hex_str = str[index + 1 .. index + 2]
ch = hex_str.hex
arr.put_bytes([ch])
index += 3
else
arr.put_bytes(c)
index += 1
end
end
if(StringUtil.empty?(enc))
return arr.buf
else
return arr.buf.encode(enc)
end
end
|