Nkfex

nkf implemented in NIFs for Elixir.

Installation

the package can be installed by adding nkfex to your list of dependencies in mix.exs:

def deps do
  [
    {:nkfex, "~> 0.1.0"}
  ]
end

Usage

encode the string:

You should specify options with single quotes.

iex > {:ok, str} = Nkfex.nkf('-s', "寒くなると、山の手大通りの露店に古着屋の数が殖える。")
{:ok,
 <<138, 166, 130, 173, 130, 200, 130, 233, 130, 198, 129, 65, 142, 82, 130, 204,
   142, 232, 145, 229, 146, 202, 130, 232, 130, 204, 152, 73, 147, 88, 130, 201,
   140, 195, 146, 133, 137, 174, 130, 204, 144, 148, 130, 170, 144, 66, 130,
   166, ...>>}

guess the encoding:

iex > Nkfex.guess(str)
{:ok, "Shift_JIS"}