better size check, don't crash on unicode