Fixed handling of non-ASCII characters