fixed an encoding issue when handling unicode characters