fix specifying size
workaround invalid UTF-8 sequences