as far as I can remember this totally correct:
kixtart does not support binary content types.
that's why inside all bytes are translated to a string-array.

but, even if it did, you force kixtart to translate the bytes to a string on this line:
$MidB = $sc.Eval('MIDB("'+ $string + 

so if the byte-array contains a single zero or special character, you end up messing it up.

download KiXnet