Skip to content

Instantly share code, notes, and snippets.

@mattsan
Created April 28, 2019 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsan/d41276836280f45fce8c029504b7690a to your computer and use it in GitHub Desktop.
Save mattsan/d41276836280f45fce8c029504b7690a to your computer and use it in GitHub Desktop.
文字列のエンコーディングの変換
defmodule Conv do
def get(url) do
{:ok, response} = HTTPoison.get(url)
:iconv.convert("SJIS", "UTF-8", response.body)
end
end
defmodule Conv.MixProject do
use Mix.Project
def project do
[
app: :conv,
version: "0.1.0",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
def application do
[
extra_applications: [:logger]
]
end
defp deps do
[
{:iconv, "~> 1.0"}, # https://hex.pm/packages/iconv
{:httpoison, "~> 1.5"}
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment