Update RapydScript

This commit is contained in:
Kovid Goyal 2016-04-05 17:54:00 +05:30
parent 38918988c2
commit eaeff825eb
2 changed files with 21 additions and 0 deletions

Binary file not shown.

View File

@ -30,6 +30,27 @@ def base64decode(string):
ans[i] = chars.charCodeAt(i) ans[i] = chars.charCodeAt(i)
return ans return ans
def hexlify(bytes):
ans = v'[]'
for v'var i = 0; i < bytes.length; i++':
x = bytes[i].toString(16)
if x.length is 1:
x = '0' + x
ans.push(x)
return ans.join('')
def unhexlify(string):
num = string.length // 2
if num * 2 is not string.length:
raise ValueError('string length is not a multiple of two')
ans = Uint8Array(num)
for v'var i = 0; i < num; i++':
x = parseInt(string[i*2:i*2+2], 16)
if isNaN(x):
raise ValueError('string is not hex-encoded')
ans[i] = x
return ans
utf8_decoder_table = v'''[ utf8_decoder_table = v'''[
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f