About Hangul
As I'm Korean, I'm really proud of Korean character, Hangul(한글).
Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443.
Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some Hangul ascii-art
List of characters
So, To make ASCII art, you have to know every characters represent each syllables, right?
No. There are 11172 syllables in Korean character, so it's almost impossible to hardcode it. But, there are only 24 basic characters:
ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣ
And in Korean you compose these to make all those syllables.
How to compose
24 basic characters can be separated into two part: a consonant and a vowel.
The first 14 characters ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎ
are consonants, and followingthe 10 characters ㅏㅑㅓㅕㅗㅛㅜㅠㅡㅣ
are vowels.
There are roughly 3 parts to a Korean character: initial consonant, vowel, and a final consonant.
Initial consonant
The initial consonant (초성 in Korean) is simplest part. It is just consonant, only with ㄲㄸㅃㅆㅉ
(double consonant). It placed in the top-left.
Vowel
The vowel (중성 or 모음 in Korean) is the hardest part. Here is list of the vowels:
ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ
ㅏㅐㅏㅒㅓㅔㅕㅖㅣ
go on the right side of initial consonant; ㅗㅛㅜㅠㅡ
go at the bottom; ㅘㅙㅚㅝㅞㅟㅢ
are both. For example: 가, 고, 과
.
Final consonant
The final consonant (종성 in Korean) is at the bottom. Here is list of final consonants: ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ
, or blank.
Example characters using final consonant : 각, 갌, 갏
How to decompose Unicode
See this webpage for help.
Challenge
Input is in this format: (number) Korean char (number) Korean char ...
Where (number) is optional. If a number is given, switch to a different style as specified below. 1
and 2
are ASCII only, and 3
is Unicode box-art.
Separate characters with 2 spaces. Note that not every character has the same width.
If the vowel is not ㅗㅛㅜㅠㅡ
, the following final consonant must be indented with a space.
The default style is 1
, so if first character doesn't have a number, style 1 is used.
An example input could be: 1한2글3날
or 한3글날
.
Here is list of Korean ascii art(style 1 and 2).
Here is list of Korean unicode box-art(style 3).
List of ASCII art
Style 1
ㄱ
___
|
|
ㄴ
|
|
|__
ㄷ
___
|
|___
ㄹ
___
__|
|___
ㅁ
__
| |
|__|
ㅂ
| |
|__|
|__|
ㅅ
/\
| |
| |
ㅇ
__
/ \
\__/
ㅈ
____
/\
/ \
ㅊ
__
____
/ \
ㅋ
___
___|
|
ㅌ
___
|___
|___
ㅍ
____
||
_;;_
ㅎ
__
____
()
ㄲ
_ _
| |
| |
ㄸ
_ _
| |
|_|_
ㅃ
||||
[][]
""""
ㅆ
/|/|
||||
||||
ㅉ
____
/|/|
||||
ㅏ
|
|_
|
|
ㅐ
| |
|_|
| |
| |
ㅑ
|
|_
|_
|
ㅒ
| |
|_|
|_|
| |
ㅓ
|
_|
|
|
ㅔ
||
_||
||
||
ㅕ
|
_|
_|
|
ㅖ
||
_||
_||
||
ㅗ
|
_|__
ㅘ
|
|
|_
| |
_|__|
ㅙ
| |
| |
|_|
| | |
_|__| |
ㅚ
|
|
|
| |
_|__|
ㅛ
||
_][_
ㅜ
____
|
ㅝ
|
|
|
____|
|--|
ㅞ
||
||
||
____||
|--||
ㅟ
|
|
|
____|
| |
ㅠ
____
||
ㅡ
____
ㅢ
|
|
|
|
____|
ㅣ
|
|
|
|
ㄳ
_ /|
|||
|||
ㄵ
| __
| /|
|_||
ㄶ
| __
| __
|_()
ㄺ
_ _
] |
[_ |
ㄻ
_ ++
]||
[_""
ㄼ
_ ||
][]
[_""
ㄽ
_ /|
]||
[_||
ㄾ
_ _
]|_
[_|_
ㄿ
_ __
]][
[_""
ㅀ
_ __
]__
[_()
Style 2
ㄱ
---.
:
:
ㄴ
:
:
'---
ㄷ
.---
:
'---
ㄹ
---.
.--'
'---
ㅁ
.--.
: :
'--'
ㅂ
: :
:--:
'--'
ㅅ
,.
: :
: :
ㅇ
..
( )
''
ㅈ
-.,-
;:
' `
ㅊ
--
-,.-
; :
ㅋ
---.
---:
:
ㅌ
.---
:---
'---
ㅍ
-..-
::
-''-
ㅎ
--
----
()
ㄲ
-.-.
: :
: :
ㄸ
.-.-
: :
'-'-
ㅃ
::::
[][]
''''
ㅆ
,:,:
::::
::::
ㅉ
----
,:,:
::::
ㅏ
:
:-
:
:
ㅐ
: :
:-:
: :
: :
ㅑ
:
:-
:-
:
ㅒ
: :
:-:
:-:
: :
ㅓ
:
-:
:
:
ㅔ
::
-::
::
::
ㅕ
:
-:
-:
:
ㅖ
::
-::
-::
::
ㅗ
:
-^--
ㅘ
:
:
:-
: :
-^--:
ㅙ
: :
: :
:-:
: : :
-^--: :
ㅚ
:
:
:
: :
-^--:
ㅛ
::
-^^-
ㅜ
-v--
:
ㅝ
:
:
:
-v--:
:--:
ㅞ
::
::
::
-v--::
:--::
ㅟ
:
:
:
-v--:
: :
ㅠ
-vv-
::
ㅡ
----
ㅢ
:
:
:
:
----:
ㅣ
:
:
:
:
ㄳ
-.,:
:::
:::
ㄵ
: --
: ,:
'-::
ㄶ
: --
: --
'-()
ㄺ
-.-.
.' :
'- :
ㄻ
-...
.'::
'-''
ㄼ
-.::
.'][
'-''
ㄽ
-.,:
.'::
'-::
ㄾ
-..-
.':-
'-'-
ㄿ
-...
.'][
'-''
ㅀ
-.--
.'--
'-()
Style 3
ㄱ
───┐
│
│
ㄴ
│
│
└──
ㄷ
┌───
│
└───
ㄹ
───┐
┌──┘
└───
ㅁ
┌──┐
│ │
└──┘
ㅂ
│ │
├──┤
└──┘
ㅅ
╱╲
│ │
│ │
ㅇ
╭──╮
│ │
╰──╯
ㅈ
────
╱╲
╱ ╲
ㅊ
──
────
╱ ╲
ㅋ
───┐
───┤
│
ㅌ
┌───
├───
└───
ㅍ
─┬┬─
││
─┴┴─
ㅎ
──
────
()
ㄲ
─┐─┐
│ │
│ │
ㄸ
┌─┌─
│ │
└─└─
ㅃ
││││
├┤├┤
└┘└┘
ㅆ
╱│╱│
││││
││││
ㅉ
────
╱│╱│
││││
ㅏ
│
├─
│
│
ㅐ
│ │
├─┤
│ │
│ │
ㅑ
│
├─
├─
│
ㅒ
│ │
├─┤
├─┤
│ │
ㅓ
│
─┤
│
│
ㅔ
││
─┤│
││
││
ㅕ
│
─┤
─┤
│
ㅖ
││
─┤│
─┤│
││
ㅗ
╷
─┴──
ㅘ
│
│
├─
╷ │
─┴──│
ㅙ
│ │
│ │
├─┤
╷ │ │
─┴──│ │
ㅚ
│
│
│
╷ │
─┴──│
ㅛ
╷╷
─┴┴─
ㅜ
─┬──
╵
ㅝ
│
│
│
─┬──│
╵──┤
ㅞ
││
││
││
─┬──││
╵──┤│
ㅟ
│
│
│
─┬──│
╵ │
ㅠ
─┬┬─
╵╵
ㅡ
────
ㅢ
│
│
│
│
────│
ㅣ
│
│
│
│
ㄳ
─┐╭╮
│││
│││
ㄵ
╷ ──
│ ╱│
└─╵╵
ㄶ
│ ──
│ ──
└─()
ㄺ
─┐─┐
┌┘ │
└─ ╵
ㄻ
─┐┌┐
┌┘││
└─└┘
ㄼ
─┐╷╷
┌┘├┤
└─└┘
ㄽ
─┐╭╮
┌┘││
└─╵╵
ㄾ
─┐┌─
┌┘├─
└─└─
ㄿ
─┐┬┬
┌┘││
└─┴┴
ㅀ
─┐──
┌┘──
└─()
Example input and output
1한2글3날
__ | ---. │ │
____|_ : │ ├─
() | : └── │
| ---- │
| ---. ───┐
| .--' ┌──┘
|__ '--- └───
뛟쀒3쫽
_ _|| |||||| ────│ │
| | || [][]|| ╱│╱││ │
|_|_|| """"|| ││││├─┤
____|| ____|| ╷ │ │
|--|| |--|| ─┴──│ │
_ __ _ __ ─┐─┐
]__ ]][ ┌┘ │
[_() [_"" └─ ╵
Scoring
This is code-golf, so the shortest code in bytes wins.