LoginSignup
1
0

More than 5 years have passed since last update.

clojureでurlエンコードをする

Last updated at Posted at 2018-01-28

使うライブラリ

javaでもやれそうですが、とりあえずこれを使いました。

[ring/ring-codec "1.1.0"]

サンプル

(ns foo.bar
  (:require [ring.util.codec :as codec]))

;; NG
;; これだと「ほげ」以外もエンコードされてしまう
;; "https%3A%2F%2Fqiita.com%2Fsearch%3Fq%3D%E3%81%BB%E3%81%92"
(codec/url-encode "https://qiita.com/search?q=ほげ")

;; OK
;; "https://qiita.com/search?q=%E3%81%BB%E3%81%92"
(str "https://qiita.com/search?q=" (codec/url-encode "ほげ"))
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0