Home > database >  Encode and Decode rfc2396 URLs in Nim
Encode and Decode rfc2396 URLs in Nim

Time:10-13

I'm working on an application that will work as a cli trash app (I know trash-cli exists, this is a personal project :) ), one of the problems I encountered is that your trash info (when you move something to trash, an info file is generated to store it's original location) stores the info in RFC 2396 format, so spaces becomes and an opening bracket becomes an (. (here is an example: /home/netsu/Documents/Music (copy))

My question is, how can I convert /home/netsu/Documents/Music (copy) into /home/netsu/Documents/Music (copy) and vice versa in Nim? Python has things like urllib.urlencode which I believe does this, but I don't know of such a useful feature in Nim.

CodePudding user response:

You can take a look at uri.encodeUrl and uri.decodeUrl: https://nim-lang.org/docs/uri.html#encodeUrl,string

  • Related