function intToChar(%val){ eval("%chr = \"\\x" @ convertBase(%val,"0123456789","0123456789ABCDEF") @ "\";"); return %chr;}function convertBase(%val,%atype,%btype){ %vlen = strLen(%val); %alen = strLen(%atype); %blen = strLen(%btype); for(%i = 0; %i < %vlen; %i++) %sum += striPos(%atype,getSubStr(%val,%i,1)) * mPow(%alen,%vlen - %i - 1); while(1) { %rem = %sum % %blen; %new = getSubStr(%btype,%rem,1) @ %new; %sum = mFloor(%sum / %blen); if(!%sum) break; } return %new;}
==>exec("config/intToChar.cs");Executing config/intToChar.cs.==>$f = new FileObject();==>$f.openForWrite("config/test.txt");==>$f.writeLine(intToChar(135) @ intToChar(217) @ intToChar(78));==>$f.close();==>$f.delete();
using System;using System.IO;public class ByteRead{ public static void Main(string[] args) { BinaryReader reader = new BinaryReader(File.Open(args[0],FileMode.Open)); while(true) { try { Console.WriteLine(reader.ReadByte()); } catch(EndOfStreamException e) { break; } } reader.Close(); }}
> csc ByteRead.cs> ByteRead test.txt135217781310
This line:eval("%chr = \"\\x" @ convertBase(%val,"0123456789","0123456789ABCDEF") @ "\";");Wouldn't it crash the server because it accesses a local variable in a global scope?
Nope. Eval runs in the scope it's called in.
As usual, Truce does something amazing that probably won't be used for anything.eh's like a magician.
Char 0 can never be stored in a strong, sorry. Find a way to do it without char 0.