bug fix: encode unicode control characters

added unit tests to verify the bug is fixed

added speed tests to validate my coding method