fix escape method

to work correctly with japanese characters.