How to automatically encode spaces to %20