summaryrefslogtreecommitdiff
path: root/cpan/dist/Unicode-Japanese/erlang/test1.erl
blob: 13ecd3f3d86343b5413a0dbc716484a82e1bbc17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-module(test1).
-export([test/0]).

test(FromCode, ToCode) ->
  FromText = get(FromCode),
  ToText   = get(ToCode),
  io:format("~p -> ~p ...", [FromCode, ToCode]),
  Ret = unijp:conv(FromCode, ToCode, FromText),
  case Ret of
  ToText -> io:format(" ok # ~p:~w -> ~p:~w~n", [FromCode, FromText, ToCode, Ret]);
  _      -> io:format(" not ok ~p~n", [Ret])
  end.

test() ->
  put(utf8,  [16#e6, 16#84, 16#9b]),
  put(sjis,  [16#88, 16#a4]),
  put(eucjp, [16#b0, 16#a6]),
  put(jis,   "\e$B0&\e(B"),
  put(ucs2,  [16#61, 16#1b]),
  put(ucs4,  [0, 0, 16#61, 16#1b]),

  unijp:start(),

  test(utf8, utf8),
  test(utf8, sjis),
  test(utf8, eucjp),
  test(utf8, jis),
  test(utf8, ucs2),
  test(utf8, ucs4),

  test(utf8,  utf8),
  test(sjis,  utf8),
  test(eucjp, utf8),
  test(jis,   utf8),
  test(ucs2,  utf8),
  test(ucs4,  utf8),

  unijp:stop(),
  ok.