shift-jis-elixir/lib/shift_jis.ex

15 lines
405 B
Elixir
Raw Permalink Normal View History

2022-01-01 09:41:37 +00:00
defmodule ShiftJis do
2022-01-01 10:30:51 +00:00
# Check config/config.exs to see how to enable this
@shift_jis "VENDORS/MICSFT/WINDOWS/CP932"
@doc ~S"""
iex> test = ShiftJis.encode("テスト")
<<131, 101, 131, 88, 131, 103>>
iex> ShiftJis.decode(test)
"テスト"
2022-01-01 09:41:37 +00:00
"""
2022-01-01 10:30:51 +00:00
def encode(str), do: Codepagex.from_string!(str, @shift_jis)
def decode(str), do: Codepagex.to_string!(str, @shift_jis)
2022-01-01 09:41:37 +00:00
end