Current section
Files
Jump to
Current section
Files
src/hanguleam@internal@unicode.erl
-module(hanguleam@internal@unicode).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/hanguleam/internal/unicode.gleam").
-export([disassemble_vowel_string/1, assemble_vowel_string/1, disassemble_consonant_string/1, assemble_consonant_string/1, get_codepoint_result_from_char/1, normalize_modern_jamo/1, is_complete_hangul/1, is_modern_jamo/1, is_modern_choseong/1, is_modern_jungseong/1, is_modern_jongseong/1, is_compatibility_jamo/1, is_hangul_alphabet/1, is_hangul/1, is_jungseong_range/1, is_compatibility_jungseong/1, is_compatibility_choseong/1, is_compatibility_jongseong/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/hanguleam/internal/unicode.gleam", 93).
?DOC(false).
-spec disassemble_vowel_string(binary()) -> binary().
disassemble_vowel_string(Vowel) ->
case Vowel of
<<"ㅏ"/utf8>> ->
<<"ㅏ"/utf8>>;
<<"ㅐ"/utf8>> ->
<<"ㅐ"/utf8>>;
<<"ㅑ"/utf8>> ->
<<"ㅑ"/utf8>>;
<<"ㅒ"/utf8>> ->
<<"ㅒ"/utf8>>;
<<"ㅓ"/utf8>> ->
<<"ㅓ"/utf8>>;
<<"ㅔ"/utf8>> ->
<<"ㅔ"/utf8>>;
<<"ㅕ"/utf8>> ->
<<"ㅕ"/utf8>>;
<<"ㅖ"/utf8>> ->
<<"ㅖ"/utf8>>;
<<"ㅗ"/utf8>> ->
<<"ㅗ"/utf8>>;
<<"ㅘ"/utf8>> ->
<<"ㅗㅏ"/utf8>>;
<<"ㅙ"/utf8>> ->
<<"ㅗㅐ"/utf8>>;
<<"ㅚ"/utf8>> ->
<<"ㅗㅣ"/utf8>>;
<<"ㅛ"/utf8>> ->
<<"ㅛ"/utf8>>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->
<<"ㅁ"/utf8>>;
<<"ㅂ"/utf8>> ->
<<"ㅂ"/utf8>>;
<<"ㅃ"/utf8>> ->
<<"ㅃ"/utf8>>;
<<"ㅂㅅ"/utf8>> ->
<<"ㅄ"/utf8>>;
<<"ㅅ"/utf8>> ->
<<"ㅅ"/utf8>>;
<<"ㅆ"/utf8>> ->
<<"ㅆ"/utf8>>;
<<"ㅇ"/utf8>> ->
<<"ㅇ"/utf8>>;
<<"ㅈ"/utf8>> ->
<<"ㅈ"/utf8>>;
<<"ㅉ"/utf8>> ->
<<"ㅉ"/utf8>>;
<<"ㅊ"/utf8>> ->
<<"ㅊ"/utf8>>;
<<"ㅋ"/utf8>> ->
<<"ㅋ"/utf8>>;
<<"ㅌ"/utf8>> ->
<<"ㅌ"/utf8>>;
<<"ㅍ"/utf8>> ->
<<"ㅍ"/utf8>>;
<<"ㅎ"/utf8>> ->
<<"ㅎ"/utf8>>;
_ ->
Consonant
end.
-file("src/hanguleam/internal/unicode.gleam", 222).
?DOC(false).
-spec get_codepoint_result_from_char(binary()) -> {ok, integer()} | {error, nil}.
get_codepoint_result_from_char(Char) ->
case begin
_pipe = gleam@string:to_utf_codepoints(Char),
gleam@list:first(_pipe)
end of
{ok, Codepoint} ->
{ok, gleam_stdlib:identity(Codepoint)};
{error, _} ->
{error, nil}
end.
-file("src/hanguleam/internal/unicode.gleam", 318).
?DOC(false).
-spec normalize_modern_jamo(binary()) -> binary().
normalize_modern_jamo(Jamo) ->
case Jamo of
<<"ᄀ"/utf8>> ->
<<"ㄱ"/utf8>>;
<<"ᄁ"/utf8>> ->
<<"ㄲ"/utf8>>;
<<"ᄂ"/utf8>> ->
<<"ㄴ"/utf8>>;
<<"ᄃ"/utf8>> ->
<<"ㄷ"/utf8>>;
<<"ᄄ"/utf8>> ->
<<"ㄸ"/utf8>>;
<<"ᄅ"/utf8>> ->
<<"ㄹ"/utf8>>;
<<"ᄆ"/utf8>> ->
<<"ㅁ"/utf8>>;
<<"ᄇ"/utf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8>>;
<<"ᇂ"/utf8>> ->
<<"ㅎ"/utf8>>;
_ ->
Jamo
end.
-file("src/hanguleam/internal/unicode.gleam", 230).
?DOC(false).
-spec is_complete_hangul(integer()) -> boolean().
is_complete_hangul(Codepoint) ->
(16#AC00 =< Codepoint) andalso (Codepoint =< 16#D7A3).
-file("src/hanguleam/internal/unicode.gleam", 235).
?DOC(false).
-spec is_modern_jamo(integer()) -> boolean().
is_modern_jamo(Codepoint) ->
(16#1100 =< Codepoint) andalso (Codepoint =< 16#11FF).
-file("src/hanguleam/internal/unicode.gleam", 260).
?DOC(false).
-spec is_modern_choseong(binary()) -> boolean().
is_modern_choseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
(Codepoint >= 16#1100) andalso (Codepoint =< 16#1112);
{error, _} ->
false
end.
-file("src/hanguleam/internal/unicode.gleam", 280).
?DOC(false).
-spec is_modern_jungseong(binary()) -> boolean().
is_modern_jungseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
(Codepoint >= 16#1161) andalso (Codepoint =< 16#1175);
{error, _} ->
false
end.
-file("src/hanguleam/internal/unicode.gleam", 297).
?DOC(false).
-spec is_modern_jongseong(binary()) -> boolean().
is_modern_jongseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
(Codepoint >= 16#11A8) andalso (Codepoint =< 16#11C2);
{error, _} ->
false
end.
-file("src/hanguleam/internal/unicode.gleam", 240).
?DOC(false).
-spec is_compatibility_jamo(integer()) -> boolean().
is_compatibility_jamo(Codepoint) ->
(16#3131 =< Codepoint) andalso (Codepoint =< 16#3163).
-file("src/hanguleam/internal/unicode.gleam", 245).
?DOC(false).
-spec is_hangul_alphabet(integer()) -> boolean().
is_hangul_alphabet(Codepoint) ->
is_modern_jamo(Codepoint) orelse is_compatibility_jamo(Codepoint).
-file("src/hanguleam/internal/unicode.gleam", 255).
?DOC(false).
-spec is_hangul(integer()) -> boolean().
is_hangul(Codepoint) ->
is_complete_hangul(Codepoint) orelse is_hangul_alphabet(Codepoint).
-file("src/hanguleam/internal/unicode.gleam", 250).
?DOC(false).
-spec is_jungseong_range(integer()) -> boolean().
is_jungseong_range(Codepoint) ->
(Codepoint >= 16#314F) andalso (Codepoint =< 16#3163).
-file("src/hanguleam/internal/unicode.gleam", 289).
?DOC(false).
-spec is_compatibility_jungseong(binary()) -> boolean().
is_compatibility_jungseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
(Codepoint >= 16#314F) andalso (Codepoint =< 16#3163);
{error, _} ->
false
end.
-file("src/hanguleam/internal/unicode.gleam", 269).
?DOC(false).
-spec is_compatibility_choseong(binary()) -> boolean().
is_compatibility_choseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
((Codepoint >= 16#3131) andalso (Codepoint =< 16#314E)) andalso gleam@list:contains(
[<<"ㄱ"/utf8>>,
<<"ㄲ"/utf8>>,
<<"ㄴ"/utf8>>,
<<"ㄷ"/utf8>>,
<<"ㄸ"/utf8>>,
<<"ㄹ"/utf8>>,
<<"ㅁ"/utf8>>,
<<"ㅂ"/utf8>>,
<<"ㅃ"/utf8>>,
<<"ㅅ"/utf8>>,
<<"ㅆ"/utf8>>,
<<"ㅇ"/utf8>>,
<<"ㅈ"/utf8>>,
<<"ㅉ"/utf8>>,
<<"ㅊ"/utf8>>,
<<"ㅋ"/utf8>>,
<<"ㅌ"/utf8>>,
<<"ㅍ"/utf8>>,
<<"ㅎ"/utf8>>],
Char
);
{error, _} ->
false
end.
-file("src/hanguleam/internal/unicode.gleam", 306).
?DOC(false).
-spec is_compatibility_jongseong(binary()) -> boolean().
is_compatibility_jongseong(Char) ->
case get_codepoint_result_from_char(Char) of
{ok, Codepoint} ->
((Codepoint >= 16#3131) andalso (Codepoint =< 16#314E)) andalso gleam@list:contains(
[<<""/utf8>>,
<<"ㄱ"/utf8>>,
<<"ㄲ"/utf8>>,
<<"ㄳ"/utf8>>,
<<"ㄴ"/utf8>>,
<<"ㄵ"/utf8>>,
<<"ㄶ"/utf8>>,
<<"ㄷ"/utf8>>,
<<"ㄹ"/utf8>>,
<<"ㄺ"/utf8>>,
<<"ㄻ"/utf8>>,
<<"ㄼ"/utf8>>,
<<"ㄽ"/utf8>>,
<<"ㄾ"/utf8>>,
<<"ㄿ"/utf8>>,
<<"ㅀ"/utf8>>,
<<"ㅁ"/utf8>>,
<<"ㅂ"/utf8>>,
<<"ㅄ"/utf8>>,
<<"ㅅ"/utf8>>,
<<"ㅆ"/utf8>>,
<<"ㅇ"/utf8>>,
<<"ㅈ"/utf8>>,
<<"ㅊ"/utf8>>,
<<"ㅋ"/utf8>>,
<<"ㅌ"/utf8>>,
<<"ㅍ"/utf8>>,
<<"ㅎ"/utf8>>],
Char
);
{error, _} ->
false
end.