Avoid relying on default charset
Improve handling of interrupted state