Util(3)
π NAME π
okay so bestie, meet Lingua::KO::Hangul::Util β that's Util(3) in the manual lineup π
β a whole lil bag of utility functions for Hangul in Unicode. Korean script? We're decoding it, no cap. β¨
πΈ SYNOPSIS πΈ
use Lingua::KO::Hangul::Util qw(:all);
decomposeSyllable("\x{AC00}"); # "\x{1100}\x{1161}"
composeSyllable("\x{1100}\x{1161}"); # "\x{AC00}"
decomposeJamo("\x{1101}"); # "\x{1100}\x{1100}"
composeJamo("\x{1100}\x{1100}"); # "\x{1101}"
getHangulName(0xAC00); # "HANGUL SYLLABLE GA"
parseHangulName("HANGUL SYLLABLE GA"); # 0xAC00
π¦ DESCRIPTION π¦
So a Hangul syllable is literally made out of Hangul jamo (that's Hangul letters, bestie).
And those letters fall into three classes, slay:
- CHOSEONG β the initial sound, aka a leading consonant (L)
- JUNGSEONG β the medial sound, aka a vowel (V)
- JONGSEONG β the final sound, aka a trailing consonant (T)
Any Hangul syllable is a composition of either (i) L + V, or (ii) L + V + T. That's the whole tea. π΅
β¨ Composition and Decomposition β¨
$resultant_string = decomposeSyllable($string)β it decomposes a precomposed syllable (LVorLVT) into a sequence of conjoining jamo (L + VorL + V + T) and hands the result back as a string. Any characters that aren't Hangul syllables are not affected β they just vibe through untouched. π«Ά$resultant_string = composeSyllable($string)β it composes a sequence of conjoining jamo (L + VorL + V + T) into a precomposed syllable (LVorLVT) when that's possible, and returns the result as a string. A syllableLVplus a final jamoTalso get composed. Any characters other than Hangul jamo and syllables are not affected. π$resultant_string = decomposeJamo($string)β it decomposes a complex jamo into a sequence of simple jamo when possible, and returns the result as a string. Any characters that aren't complex jamo are not affected.
e.g.
CHOSEONG SIOS-PIEUP to CHOSEONG SIOS + PIEUP
JUNGSEONG AE to JUNGSEONG A + I
JUNGSEONG WE to JUNGSEONG U + EO + I
JONGSEONG SSANGSIOS to JONGSEONG SIOS + SIOS
$resultant_string = composeJamo($string)β it composes a sequence of simple jamo (L1 + L2,V1 + V2 + V3, etc.) into a complex jamo when possible, and returns the result as a string. Any characters that aren't simple jamo are not affected.
e.g.
CHOSEONG SIOS + PIEUP to CHOSEONG SIOS-PIEUP
JUNGSEONG A + I to JUNGSEONG AE
JUNGSEONG U + EO + I to JUNGSEONG WE
JONGSEONG SIOS + SIOS to JONGSEONG SSANGSIOS
$resultant_string = decomposeFull($string)β it decomposes a syllable/complex jamo into a sequence of simple jamo. It's equivalent todecomposeJamo(decomposeSyllable($string)). Same energy, one call. π«
π Composition and Decomposition (Old-interface, deprecated!) π
bestie. DEPRECATED. Like, the old interface. It still works but it's giving legacy code, and you should know that going in. π
$string_decomposed = decomposeHangul($code_point)@codepoints = decomposeHangul($code_point)
If the code point you hand over is a Hangul syllable, it returns a list of code points (in list context) or a string (in scalar context) of its decomposition.
decomposeHangul(0xAC00) # U+AC00 is HANGUL SYLLABLE GA.
returns "\x{1100}\x{1161}" or (0x1100, 0x1161);
decomposeHangul(0xAE00) # U+AE00 is HANGUL SYLLABLE GEUL.
returns "\x{1100}\x{1173}\x{11AF}" or (0x1100, 0x1173, 0x11AF);
Otherwise, it returns false (empty string or empty list).
decomposeHangul(0x0041) # outside Hangul syllables
returns empty string or empty list.
$string_composed = composeHangul($src_string)@code_points_composed = composeHangul($src_string)
Any sequence of an initial jamo L and a medial jamo V gets composed into a syllable LV; then any sequence of a syllable LV and a final jamo T gets composed into a syllable LVT.
Any characters other than Hangul jamo and syllables are not affected.
composeHangul("\x{1100}\x{1173}\x{11AF}.")
# returns "\x{AE00}." or (0xAE00,0x2E);
$code_point_composite = getHangulComposite($code_point_here, $code_point_next)β it returns the codepoint of the composite if both code points,$code_point_hereand$code_point_next, are in Hangul and composable. Otherwise it returnsundef. That's it, that's the deal. π
π Hangul Syllable Name π
Heads up: the following functions handle only a precomposed Hangul syllable (from U+AC00 to U+D7A3) β not a Hangul jamo, not any other Hangul-related character. Know the limit, bestie.
Names of Hangul syllables have a format of HANGUL SYLLABLE %s. Iconic format tbh.
$name = getHangulName($code_point)β if the code point is a Hangul syllable, it returns the name; otherwise it returnsundef.
getHangulName(0xAC00) returns "HANGUL SYLLABLE GA";
getHangulName(0x0041) returns undef.
$codepoint = parseHangulName($name)β if the name is a Hangul syllable's name, it returns the code point; otherwise it returnsundef.
parseHangulName("HANGUL SYLLABLE GEUL") returns 0xAE00;
parseHangulName("LATIN SMALL LETTER A") returns undef;
parseHangulName("HANGUL SYLLABLE PERL") returns undef;
# Regrettably, HANGUL SYLLABLE PERL does not exist :-)
π Standard Korean Syllable Block π
So a standard Korean syllable block is L+ V+ T* β that's a sequence of one or more L, one or more V, and zero or more T β according to the conjoining jamo behavior revised in Unicode 3.2 (cf. UAX #28). And lowkey important: a sequence of L followed by T is not a syllable block without V. It's actually two nonstandard syllable blocks: one without V, and another without L and V. Messy, but that's the rules. π
$bool = isStandardForm($string)β returns a boolean for whether the string is encoded in the standard form, with no nonstandard sequence in it. It returns true only if the string contains no nonstandard sequence.$resultant_string = insertFiller($string)β transforms the string into standard form by inserting fillers into each syllable, and returns the result as a string. Choseong filler (Lf,U+115F) gets inserted into a syllable block withoutL. Jungseong filler (Vf,U+1160) gets inserted into a syllable block withoutV. Fillers are the little glow-ups β¨$type = getSyllableType($code_point)β returns the Hangul syllable type (cf.HangulSyllableType.txt) for the code point, as a string:Lfor leading jamo,Vfor vowel jamo,Tfor trailing jamo,LVfor LV syllables,LVTfor LVT syllables, andNAfor other code points (as Not Applicable). Six possible answers, zero ambiguity. π―
π EXPORT π
By default:
decomposeHangul
composeHangul
getHangulName
parseHangulName
getHangulComposite
On request:
decomposeSyllable
composeSyllable
decomposeJamo
composeJamo
decomposeFull
isStandardForm
insertFiller
getSyllableType
π CAVEAT π
Real talk: this module does not support Hangul jamo assigned in Unicode 5.2.0 (2009). If you were looking for those, this isn't the module, bestie, sorry. π
A list of Hangul characters this module supports:
1100..1159 ; 1.1 # [90] HANGUL CHOSEONG KIYEOK..HANGUL CHOSEONG YEORINHIEUH
115F..11A2 ; 1.1 # [68] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG SSANGARAEA
11A8..11F9 ; 1.1 # [82] HANGUL JONGSEONG KIYEOK..HANGUL JONGSEONG YEORINHIEUH
AC00..D7A3 ; 2.0 # [11172] HANGUL SYLLABLE GA..HANGUL SYLLABLE HIH
π«Ά AUTHOR π«Ά
SADAHIRO Tomoyuki <SADAHIRO@cpan.org>
Copyright(C) 2001, 2003, 2005, SADAHIRO Tomoyuki. Japan. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Free as in go off, bestie. π
π SEE ALSO π
- Unicode Normalization Forms (UAX #15) β <http://www.unicode.org/reports/tr15/>
- Conjoining Jamo Behavior (revision) in UAX #28 β <http://www.unicode.org/reports/tr28/#3_11_conjoining_jamo_behavior>
- Hangul Syllable Type β <http://www.unicode.org/Public/UNIDATA/HangulSyllableType.txt>
- Jamo Decomposition in Old Unicode β <http://www.unicode.org/Public/2.1-Update3/UnicodeData-2.1.8.txt>
- ISO/IEC JTC1/SC22/WG20 N954 β Paper by K. KIM: New canonical decomposition and composition processes for Hangeul β <http://std.dkuug.dk/JTC1/SC22/WG20/docs/N954.PDF> (summary: <http://std.dkuug.dk/JTC1/SC22/WG20/docs/N953.PDF>) (cf. <http://std.dkuug.dk/JTC1/SC22/WG20/docs/documents.html>)
and that's the whole page, bestie!! this lil manual is riding with perl v5.42.0, dated 2025-07-25, and it's filed under Util(3) β go forth and decompose some syllables, you absolute icon ππ
π¦ where this page comes from
- fedora 43: perl-Lingua-KO-Hangul-Util 0.28-27.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms