patched for non-ASCII characters.