encode URI before parsing