Added sha384.fun to std library and alot of fixes. (0.16.3)
This commit is contained in:
parent
f0ed1d6761
commit
17241b2401
18 changed files with 820 additions and 314 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://hanez.org/project/fun/
|
||||
*
|
||||
|
|
@ -9,54 +9,7 @@
|
|||
* Added: 2025-10-01
|
||||
*/
|
||||
|
||||
// ASCII string to bytes (printable ASCII 0x20..0x7E)
|
||||
fun string_to_bytes_ascii(this, s)
|
||||
str = to_string(s)
|
||||
out = []
|
||||
number i = 0
|
||||
// ASCII printable ranges
|
||||
P1 = " !\"#$%&'()*+,-./" // 32..47
|
||||
P2 = "0123456789" // 48..57
|
||||
P3 = ":;<=>?@" // 58..64
|
||||
P4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 65..90
|
||||
P5 = "[\\]^_`" // 91..96
|
||||
P6 = "abcdefghijklmnopqrstuvwxyz" // 97..122
|
||||
P7 = "{|}~" // 123..126
|
||||
while true
|
||||
ch = substr(str, i, 1)
|
||||
if (typeof(ch) != "String" || ch == "")
|
||||
break
|
||||
number code = -1
|
||||
idx = find(P1, ch)
|
||||
if (idx >= 0)
|
||||
code = 32 + idx
|
||||
else
|
||||
idx = find(P2, ch)
|
||||
if (idx >= 0)
|
||||
code = 48 + idx
|
||||
else
|
||||
idx = find(P3, ch)
|
||||
if (idx >= 0)
|
||||
code = 58 + idx
|
||||
else
|
||||
idx = find(P4, ch)
|
||||
if (idx >= 0)
|
||||
code = 65 + idx
|
||||
else
|
||||
idx = find(P5, ch)
|
||||
if (idx >= 0)
|
||||
code = 91 + idx
|
||||
else
|
||||
idx = find(P6, ch)
|
||||
if (idx >= 0)
|
||||
code = 97 + idx
|
||||
else
|
||||
idx = find(P7, ch)
|
||||
if (idx >= 0)
|
||||
code = 123 + idx
|
||||
else
|
||||
// non-printable -> 0
|
||||
code = 0
|
||||
push(out, code)
|
||||
i = i + 1
|
||||
return out
|
||||
// This file should not contain code! It should just include all string related
|
||||
// functions from core/*.fun.
|
||||
|
||||
#include <core/string_to_bytes_ascii.fun>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue