char literals
This commit is contained in:
25
src/std.zr
25
src/std.zr
@@ -12,7 +12,7 @@ func print_i64[x: I64] : I64
|
||||
return 0
|
||||
|
||||
func String.is_whitespace[c: U8] : Bool
|
||||
return c == 10 || c == 32 || c == 13 || c == 9
|
||||
return c == ' ' || c == 10 || c == 13 || c == 9
|
||||
|
||||
func String.concat[a: String, b: String] : String
|
||||
let c: String = malloc(strlen(a) + strlen(b) + 1)
|
||||
@@ -83,7 +83,7 @@ func IO.write_file[path: String, content: String] : I64
|
||||
return 0
|
||||
|
||||
func U8.parse_i64[c: U8]: I64
|
||||
return c - 48
|
||||
return c - '0'
|
||||
|
||||
func I64.to_string[n: I64] : String
|
||||
let x: String = malloc(21)
|
||||
@@ -183,17 +183,17 @@ func Crypto.hex_encode[s: String] : String
|
||||
return out
|
||||
|
||||
func Crypto.from_hex_digit[d: U8] : I64
|
||||
if d == 97
|
||||
if d == 'a'
|
||||
return 10
|
||||
if d == 98
|
||||
if d == 'b'
|
||||
return 11
|
||||
if d == 99
|
||||
if d == 'c'
|
||||
return 12
|
||||
if d == 100
|
||||
if d == 'd'
|
||||
return 13
|
||||
if d == 101
|
||||
if d == 'e'
|
||||
return 14
|
||||
if d == 102
|
||||
if d == 'f'
|
||||
return 15
|
||||
return U8.parse_i64(d)
|
||||
|
||||
@@ -268,12 +268,11 @@ func Crypto.base64_encode[s: String] : String
|
||||
j = j + 4
|
||||
|
||||
let padding: I64 = s_len % 3
|
||||
let equals: U8 = String.nth("=", 0)
|
||||
if padding == 1
|
||||
String.set(output, j-2, equals)
|
||||
String.set(output, j-1, equals)
|
||||
String.set(output, j-2, '=')
|
||||
String.set(output, j-1, '=')
|
||||
else if padding == 2
|
||||
String.set(output, j-1, equals)
|
||||
String.set(output, j-1, '=')
|
||||
|
||||
String.set(output, j, 0)
|
||||
return output
|
||||
@@ -285,7 +284,7 @@ func Crypto.base64_decode[s: String] : String
|
||||
let i: I64 = 0
|
||||
let j: I64 = 0
|
||||
|
||||
while String.nth(s, s_len-1) == 61
|
||||
while String.nth(s, s_len-1) == '='
|
||||
s_len = s_len - 1
|
||||
|
||||
while i < s_len
|
||||
|
||||
Reference in New Issue
Block a user