encoding fix

now it truncates \0 at the end