Closed casouri closed 3 years ago
This might work for you: parse the URI first and then re-convert it to a string:
> (url->string (string->url "http://mysite.com/this place<"))
"http://mysite.com/this%20place%3C"
If that doesn’t quite cut it, you could parse the string into url
struct with string->url
and then do your own encoding on just the path portion.
I thought I replied and thanked you but apparently not. I hope this isn't too late ;-) Thanks! Using url->string
with string->url
works great.
I have a bunch of urls that contain Unicode, and I need to encode them. The problem is,
encode-uri
provided innet/uri-codec
encodes reserved characters, sohttps://mysite.com
becomeshttps%3A%2F%2Fmysite.com
. What I really want is to not encode reserved characters and only encode non-ascii characters. I looked around and couldn't find a function that suits my needs. I could roll my own, but surely someone has figured it out, right?