1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

概要

paiza.ioでelixirやってみた。
URI使ってみた。

サンプルコード



URI.decode("https%3A%2F%2Felixir-lang.org")
|> IO.inspect

URI.decode_query("foo=1&bar=2")
|> IO.inspect

URI.encode("ftp://s-ite.tld/?value=put it+й")
|> IO.inspect

URI.encode("a string", &(&1 != ?i))
|> IO.inspect

query = %{"foo" => 1, "bar" => 2}
URI.encode_query(query)
|> IO.inspect

URI.merge(URI.parse("http://google.com"), "/query") 
|> to_string()
|> IO.inspect

URI.parse("https://elixir-lang.org/")
|> IO.inspect

URI.query_decoder("foo=1&bar=2") 
|> Enum.to_list()
|> IO.inspect

uri = URI.parse("http://google.com")
URI.to_string(uri)
|> IO.inspect


query = URI.encode_query(%{q: "山形県東置賜郡川西町"})
|> IO.inspect




"ok"
|> String.to_charlist
|> IO.inspect

url = "https://msearch.gsi.go.jp/address-search/AddressSearch?" <> query
url = String.to_charlist(url)
|> IO.inspect



実行結果

"https://elixir-lang.org"
%{"bar" => "2", "foo" => "1"}
"ftp://s-ite.tld/?value=put%20it+%D0%B9"
"a str%69ng"
"bar=2&foo=1"
"http://google.com/query"
%URI{
  authority: "elixir-lang.org",
  fragment: nil,
  host: "elixir-lang.org",
  path: "/",
  port: 443,
  query: nil,
  scheme: "https",
  userinfo: nil
}
[{"foo", "1"}, {"bar", "2"}]
"http://google.com"
"q=%E5%B1%B1%E5%BD%A2%E7%9C%8C%E6%9D%B1%E7%BD%AE%E8%B3%9C%E9%83%A1%E5%B7%9D%E8%A5%BF%E7%94%BA"
'ok'
'https://msearch.gsi.go.jp/address-search/AddressSearch?q=%E5%B1%B1%E5%BD%A2%E7%9C%8C%E6%9D%B1%E7%BD%AE%E8%B3%9C%E9%83%A1%E5%B7%9D%E8%A5%BF%E7%94%BA'

成果物

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?