Revised for multibyte characters
Added test case