go_hangul: github.com/suapapa/go_hangul Index | Examples | Files | Directories

package hangul

import "github.com/suapapa/go_hangul"

Package hangul provide handy tools for manipulate korean character:

- Provide shorthands for korean consonants and vowels
- Convert between jamo and compatibility-jamo
- Split a character to it's three elements
- Split multi element
- Stroke count

Index

Examples

Package Files

constant.go constant_deperecate.go hangul.go jamo.go stroke.go

Constants

const (
    G   // HANGUL LETTER KIYEOK
    GG  // HANGUL LETTER SSANGKIYEOK
    GS  // HANGUL LETTER KIYEOK-SIOS
    N   // HANGUL LETTER NIEUN
    NJ  // HANGUL LETTER NIEUN-CIEUC
    NH  // HANGUL LETTER NIEUN-HIEUH
    D   // HANGUL LETTER TIKEUT
    DD  // HANGUL LETTER SSANGTIKEUT
    L   // HANGUL LETTER RIEUL
    LG  // HANGUL LETTER RIEUL-KIYEOK
    LM  // HANGUL LETTER RIEUL-MIEUM
    LB  // HANGUL LETTER RIEUL-PIEUP
    LS  // HANGUL LETTER RIEUL-SIOS
    LT  // HANGUL LETTER RIEUL-THIEUTH
    LP  // HANGUL LETTER RIEUL-PHIEUPH
    LH  // HANGUL LETTER RIEUL-HIEUH
    M   // HANGUL LETTER MIEUM
    B   // HANGUL LETTER PIEUP
    BB  // HANGUL LETTER SSANGPIEUP
    BS  // HANGUL LETTER PIEUP-SIOS
    S   // HANGUL LETTER SIOS
    SS  // HANGUL LETTER SSANGSIOS
    ZS  // HANGUL LETTER IEUNG (zero sound)
    J   // HANGUL LETTER CIEUC
    JJ  // HANGUL LETTER SSANGCIEUC
    C   // HANGUL LETTER CHIEUCH
    K   // HANGUL LETTER KHIEUKH
    T   // HANGUL LETTER THIEUTH
    P   // HANGUL LETTER PHIEUPH
    H   // HANGUL LETTER HIEUH
    A   // HANGUL LETTER A
    AE  // HANGUL LETTER AE
    YA  // HANGUL LETTER YA
    YAE // HANGUL LETTER YAE
    EO  // HANGUL LETTER EO
    E   // HANGUL LETTER E
    YEO // HANGUL LETTER YEO
    YE  // HANGUL LETTER YE
    O   // HANGUL LETTER O
    WA  // HANGUL LETTER WA
    WAE // HANGUL LETTER WAE
    OE  // HANGUL LETTER OE
    YO  // HANGUL LETTER YO
    U   // HANGUL LETTER U
    WEO // HANGUL LETTER WEO
    WE  // HANGUL LETTER WE
    WI  // HANGUL LETTER WI
    YU  // HANGUL LETTER YU
    EU  // HANGUL LETTER EU
    YI  // HANGUL LETTER YI
    I   // HANGUL LETTER I
    NG  = ZS
)

Hangul Compatibility Jamo. Range: 3130-318F

const (
    LeadG  // HANGUL CHOSEONG KIYEOK
    LeadGG // HANGUL CHOSEONG SSANGKIYEOK
    LeadN  // HANGUL CHOSEONG NIEUN
    LeadD  // HANGUL CHOSEONG TIKEUT
    LeadDD // HANGUL CHOSEONG SSANGTIKEUT
    LeadR  // HANGUL CHOSEONG RIEUL
    LeadM  // HANGUL CHOSEONG MIEUM
    LeadB  // HANGUL CHOSEONG PIEUP
    LeadBB // HANGUL CHOSEONG SSANGPIEUP
    LeadS  // HANGUL CHOSEONG SIOS
    LeadSS // HANGUL CHOSEONG SSANGSIOS
    LeadZS // HANGUL CHOSEONG IEUNG (zero sound)
    LeadJ  // HANGUL CHOSEONG CIEUC
    LeadJJ // HANGUL CHOSEONG SSANGCIEUC
    LeadC  // HANGUL CHOSEONG CHIEUCH
    LeadK  // HANGUL CHOSEONG KHIEUKH
    LeadT  // HANGUL CHOSEONG THIEUTH
    LeadP  // HANGUL CHOSEONG PHIEUPH
    LeadH  // HANGUL CHOSEONG HIEUH
)

Initial consonants 초성

const (
    MedialA   // HANGUL JUNGSEONG A
    MedialAE  // HANGUL JUNGSEONG AE
    MedialYA  // HANGUL JUNGSEONG YA
    MedialYAE // HANGUL JUNGSEONG YAE
    MedialEO  // HANGUL JUNGSEONG EO
    MedialE   // HANGUL JUNGSEONG E
    MedialYEO // HANGUL JUNGSEONG YEO
    MedialYE  // HANGUL JUNGSEONG YE
    MedialO   // HANGUL JUNGSEONG O
    MedialWA  // HANGUL JUNGSEONG WA
    MedialWAE // HANGUL JUNGSEONG WAE
    MedialOE  // HANGUL JUNGSEONG OE
    MedialYO  // HANGUL JUNGSEONG YO
    MedialU   // HANGUL JUNGSEONG U
    MedialWEO // HANGUL JUNGSEONG WEO
    MedialWE  // HANGUL JUNGSEONG WE
    MedialWI  // HANGUL JUNGSEONG WI
    MedialYU  // HANGUL JUNGSEONG YU
    MedialEU  // HANGUL JUNGSEONG EU
    MedialYI  // HANGUL JUNGSEONG YI
    MedialI   // HANGUL JUNGSEONG I
)

Medial vowels 중성

const (
    TailG  // HANGUL JONGSEONG KIYEOK
    TailGG // HANGUL JONGSEONG SSANGKIYEOK
    TailGS // HANGUL JONGSEONG KIYEOK-SIOS
    TailN  // HANGUL JONGSEONG NIEUN
    TailNJ // HANGUL JONGSEONG NIEUN-CIEUC
    TailNH // HANGUL JONGSEONG NIEUN-HIEUH
    TailD  // HANGUL JONGSEONG TIKEUT
    TailL  // HANGUL JONGSEONG RIEUL
    TailLG // HANGUL JONGSEONG RIEUL-KIYEOK
    TailLM // HANGUL JONGSEONG RIEUL-MIEUM
    TailLB // HANGUL JONGSEONG RIEUL-PIEUP
    TailLS // HANGUL JONGSEONG RIEUL-SIOS
    TailLT // HANGUL JONGSEONG RIEUL-THIEUTH
    TailLP // HANGUL JONGSEONG RIEUL-PHIEUPH
    TailLH // HANGUL JONGSEONG RIEUL-HIEUH
    TailM  // HANGUL JONGSEONG MIEUM
    TailB  // HANGUL JONGSEONG PIEUP
    TailBS // HANGUL JONGSEONG PIEUP-SIOS
    TailS  // HANGUL JONGSEONG SIOS
    TailSS // HANGUL JONGSEONG SSANGSIOS
    TailNG // HANGUL JONGSEONG IEUNG
    TailJ  // HANGUL JONGSEONG CIEUC
    TailC  // HANGUL JONGSEONG CHIEUCH
    TailK  // HANGUL JONGSEONG KHIEUKH
    TailT  // HANGUL JONGSEONG THIEUTH
    TailP  // HANGUL JONGSEONG PHIEUPH
    TailH  // HANGUL JONGSEONG HIEUH
)

Final consonants 종성

const (
    LEAD_BASE   = 0x1100 // HANGUL CHOSEONG KIYEOK
    MEDIAL_BASE = 0x1161 // HANGUL JUNGSEONG A
    TAIL_BASE   = 0x11A8 // HANGUL JONGSEONG KIYEOK
)

Hangul Jamo. Range 1100-11FF

const (
    LEAD_G  // HANGUL CHOSEONG KIYEOK
    LEAD_GG // HANGUL CHOSEONG SSANGKIYEOK
    LEAD_N  // HANGUL CHOSEONG NIEUN
    LEAD_D  // HANGUL CHOSEONG TIKEUT
    LEAD_DD // HANGUL CHOSEONG SSANGTIKEUT
    LEAD_R  // HANGUL CHOSEONG RIEUL
    LEAD_M  // HANGUL CHOSEONG MIEUM
    LEAD_B  // HANGUL CHOSEONG PIEUP
    LEAD_BB // HANGUL CHOSEONG SSANGPIEUP
    LEAD_S  // HANGUL CHOSEONG SIOS
    LEAD_SS // HANGUL CHOSEONG SSANGSIOS
    LEAD_ZS // HANGUL CHOSEONG IEUNG (zero sound)
    LEAD_J  // HANGUL CHOSEONG CIEUC
    LEAD_JJ // HANGUL CHOSEONG SSANGCIEUC
    LEAD_C  // HANGUL CHOSEONG CHIEUCH
    LEAD_K  // HANGUL CHOSEONG KHIEUKH
    LEAD_T  // HANGUL CHOSEONG THIEUTH
    LEAD_P  // HANGUL CHOSEONG PHIEUPH
    LEAD_H  // HANGUL CHOSEONG HIEUH
)

Initial consonants 초성

const (
    MEDIAL_A   // HANGUL JUNGSEONG A
    MEDIAL_AE  // HANGUL JUNGSEONG AE
    MEDIAL_YA  // HANGUL JUNGSEONG YA
    MEDIAL_YAE // HANGUL JUNGSEONG YAE
    MEDIAL_EO  // HANGUL JUNGSEONG EO
    MEDIAL_E   // HANGUL JUNGSEONG E
    MEDIAL_YEO // HANGUL JUNGSEONG YEO
    MEDIAL_YE  // HANGUL JUNGSEONG YE
    MEDIAL_O   // HANGUL JUNGSEONG O
    MEDIAL_WA  // HANGUL JUNGSEONG WA
    MEDIAL_WAE // HANGUL JUNGSEONG WAE
    MEDIAL_OE  // HANGUL JUNGSEONG OE
    MEDIAL_YO  // HANGUL JUNGSEONG YO
    MEDIAL_U   // HANGUL JUNGSEONG U
    MEDIAL_WEO // HANGUL JUNGSEONG WEO
    MEDIAL_WE  // HANGUL JUNGSEONG WE
    MEDIAL_WI  // HANGUL JUNGSEONG WI
    MEDIAL_YU  // HANGUL JUNGSEONG YU
    MEDIAL_EU  // HANGUL JUNGSEONG EU
    MEDIAL_YI  // HANGUL JUNGSEONG YI
    MEDIAL_I   // HANGUL JUNGSEONG I
)

Medial vowels 중성

const (
    TAIL_G  // HANGUL JONGSEONG KIYEOK
    TAIL_GG // HANGUL JONGSEONG SSANGKIYEOK
    TAIL_GS // HANGUL JONGSEONG KIYEOK-SIOS
    TAIL_N  // HANGUL JONGSEONG NIEUN
    TAIL_NJ // HANGUL JONGSEONG NIEUN-CIEUC
    TAIL_NH // HANGUL JONGSEONG NIEUN-HIEUH
    TAIL_D  // HANGUL JONGSEONG TIKEUT
    TAIL_L  // HANGUL JONGSEONG RIEUL
    TAIL_LG // HANGUL JONGSEONG RIEUL-KIYEOK
    TAIL_LM // HANGUL JONGSEONG RIEUL-MIEUM
    TAIL_LB // HANGUL JONGSEONG RIEUL-PIEUP
    TAIL_LS // HANGUL JONGSEONG RIEUL-SIOS
    TAIL_LT // HANGUL JONGSEONG RIEUL-THIEUTH
    TAIL_LP // HANGUL JONGSEONG RIEUL-PHIEUPH
    TAIL_LH // HANGUL JONGSEONG RIEUL-HIEUH
    TAIL_M  // HANGUL JONGSEONG MIEUM
    TAIL_B  // HANGUL JONGSEONG PIEUP
    TAIL_BS // HANGUL JONGSEONG PIEUP-SIOS
    TAIL_S  // HANGUL JONGSEONG SIOS
    TAIL_SS // HANGUL JONGSEONG SSANGSIOS
    TAIL_NG // HANGUL JONGSEONG IEUNG
    TAIL_J  // HANGUL JONGSEONG CIEUC
    TAIL_C  // HANGUL JONGSEONG CHIEUCH
    TAIL_K  // HANGUL JONGSEONG KHIEUKH
    TAIL_T  // HANGUL JONGSEONG THIEUTH
    TAIL_P  // HANGUL JONGSEONG PHIEUPH
    TAIL_H  // HANGUL JONGSEONG HIEUH
)

Final consonants 종성

const MAX_LEAD_IDX = LEAD_H - LEAD_G
const MAX_MEDIAL_IDX = MEDIAL_I - MEDIAL_A
const MAX_TAIL_IDX = TAIL_H - TAIL_G

func AppendPostposition Uses

func AppendPostposition(word, with, without string) string

AppendPostposition returns word with postposition(조사). The 'with' will be appended to a word that ends with consonant, and the 'without' will be appended to a word that does not end with consonant.

Code:

fmt.Println(hangul.AppendPostposition("강", "이", "가"))
fmt.Println(hangul.AppendPostposition("물고기", "은", "는"))
fmt.Println(hangul.AppendPostposition("영철", "이랑", "랑"))
fmt.Println(hangul.AppendPostposition("순희", "이랑", "랑"))
fmt.Println(hangul.AppendPostposition("마을", "으로", "로"))

Output:

강이
물고기는
영철이랑
순희랑
마을로

func CompatJamo Uses

func CompatJamo(r rune) rune

CompatJamo converts lead, medial, tail to compatibility jamo

func EndsWithConsonant Uses

func EndsWithConsonant(word string) bool

EndsWithConsonant returns true if the given word ends with consonant(종성), false otherwise.

func IsHangul Uses

func IsHangul(r rune) bool

IsHangul checks given rune is Hangul

func IsJaeum Uses

func IsJaeum(r rune) bool

IsJaeum checks given rune is Hangul Jaeum

func IsLead Uses

func IsLead(r rune) bool

IsLead checks given rune is lead consonant

func IsMedial Uses

func IsMedial(r rune) bool

IsMedial checks given rune is medial vowel

func IsMoeum Uses

func IsMoeum(r rune) bool

IsMoeum checks given rune is Hangul Moeum

func IsTail Uses

func IsTail(r rune) bool

IsTail checks given rune is tail consonant

func Join Uses

func Join(l, m, t rune) rune

Join converts NFD to NFC

func LastConsonant Uses

func LastConsonant(word string) rune

LastConsonant returns last consonant(종성). It returns 0 if last consonant not exists.

Code:

fmt.Println(hangul.LastConsonant("강"))
fmt.Println(hangul.LastConsonant("물고기"))

Output:

4540
0

func Lead Uses

func Lead(c rune) rune

Lead converts compatibility jaeum to corresponding lead consonant

func Medial Uses

func Medial(c rune) rune

Medial converts compatibility moeum to corresponding medial vowel

func Split Uses

func Split(c rune) (l, m, t rune)

Split converts NFC to NFD

func SplitCompat Uses

func SplitCompat(c rune) (l, m, t rune)

SplitCompat splits and returns l, m, t in compatibility jamo

func SplitMultiElement Uses

func SplitMultiElement(r rune) ([]rune, bool)

SplitMultiElement splits multi-element compatibility jamo

func Stroke Uses

func Stroke(r rune) (c int)

Stroke returns stroke count of given jamo.

func Tail Uses

func Tail(c rune) rune

Tail converts compatibility jaeum to corresponding tail consonant

Directories

PathSynopsis
encoding/cp949Package cp949 provide support for CP949 character encoding, It's degault encoding in Korean MS Windows.
hanja

Package hangul is imported by 2 packages. Updated 2018-09-27. Refresh now. Tools for package owners.