Swiftpack.co - eastriverlee/geulzza as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by eastriverlee.
eastriverlee/geulzza 1.0.4
"geulzza" is a super-lightweight swift library that helps dealing with korean string by decomposing each letter into jamos.
โญ๏ธ 4
๐Ÿ•“ 2 years ago
.package(url: "https://github.com/eastriverlee/geulzza.git", from: "1.0.4")

geulzza

logo

about

geulzza is a super-lightweight swift library that helps dealing with korean string by decomposing each letter into jamos.
๊ธ€์งœ๋Š” ์ž๋ชจ๋ฅผ ๋ถ„๋ฆฌํ•ด ํ•œ๊ธ€ ์ŠคํŠธ๋ง์„ ๋‹ค๋ฃจ๋Š” ๋ฐ ๋„์›€์„ ์ฃผ๋Š” ๋ฌด์ง€ ๊ฐ€๋ฒผ์šด ์Šค์œ„ํ”„ํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.

usage

import geulzza

let cent = "์œค์„์—ด"
let chicken = "๋ฐ•๊ทผํ˜œ"
let rat = "์ด๋ช…๋ฐ•"
let ashdragon = "leejaeyong"
let joogija = "JOOJINWOO"
print("\(cent.์ด๊ฐ€) \(chicken.์„๋ฅผ) ๋•Œ๋ ธ๋‹ค.")
//์œค์„์—ด์ด ๋ฐ•๊ทผํ˜œ๋ฅผ ๋•Œ๋ ธ๋‹ค.
print("\(ashdragon.์€๋Š”) ๋ฐ”๋ณด.")
//leejaeyong์€ ๋ฐ”๋ณด.
print(rat.์ด๊ฐ€ + " ์šธ์—ˆ๋‹ค.")
//์ด๋ช…๋ฐ•์ด ์šธ์—ˆ๋‹ค.
print(joogija.์€๋Š” + " ์›ƒ์—ˆ๋‹ค.")
//JOOJINWOO๋Š” ์›ƒ์—ˆ๋‹ค.

eun/neun ee/ga eul/reul will be appended depending on the last consonant.
๋ฐ›์นจ ์œ ๋ฌด, ํ˜น์€ ๋งˆ์ง€๋ง‰ ๊ธ€์ž์— ๋”ฐ๋ผ ์€/๋Š” ์ด/๊ฐ€ ์„/๋ฅผ ์„ ์„ ํƒํ•ด ๋ถ™์—ฌ์ค๋‹ˆ๋‹ค.

import geulzza

let c: Character = "์•"
let ์• = Geulzza("์•")
print(์• == c.geulzza)
print(์• == c)
print("ํ–Ÿ" == ์•)
//true
//true
//false
let ๋ฐ›์นจ = ์•.์ข…์„ฑ
print(๋ฐ›์นจ.rawValue)
//แ†ฒ
print("\(๋ฐ›์นจ.์•ž)\(c.geulzza.๋ฐ›์นจ.๋’ค)")
//ใ„นใ…‚
let cho = ์•.์ดˆ์„ฑ
let jung = ์•.์ค‘์„ฑ
let zong = ์•.์ข…์„ฑ
print("\(cho)\(jung)\(zong.rawValue)")
//ใ…‡ใ…แ†ฒ
print(Character(.ใ„ฑ, jung, .ใ„นใ…))
//๊ฐŠ
print(์•.char)
//์•
์•.์ดˆ์„ฑ = .ใ…†
print(์•.char)
//์Œƒ

composing, decomposing and editing are supported for Geulzza class.
๊ธ€์งœ ํด๋ž˜์Šค๋Š” ์กฐํ•ฉ, ํ•ด์ฒด, ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

Jaeum, Moeum and Badchim are all enum of Character type.
์ž์Œ, ๋ชจ์Œ, ๋ฐ›์นจ์€ ๋ชจ๋‘ Character ํƒ€์ž…์˜ enum์ž…๋‹ˆ๋‹ค.

structure

public class Geulzza {
    init(_ c: Character) {
        unicode = c.unicode
        guard Hex.isHangeul(unicode) else { nonHangeul = c; return }
        let offset = unicode - hangeulStart
        ์ดˆ์„ฑ = Jaeum(rawValue: ((offset / 28) / 21 + jaeumStart).char)!
        ์ค‘์„ฑ = Moeum(rawValue: ((offset / 28) % 21 + moeumStart).char)!
        ์ข…์„ฑ = Badchim(rawValue: ((offset % 28) + badchimStart).char) ?? .__
        char = Character(์ดˆ์„ฑ, ์ค‘์„ฑ, ์ข…์„ฑ)
    }
    var unicode: Hex
    var nonHangeul: Character?
    var char: Character = " "
    var ์ดˆ์„ฑ: Jaeum = .__ {
        didSet { char = Character(์ดˆ์„ฑ, ์ค‘์„ฑ, ์ข…์„ฑ) }
    }
    var ์ค‘์„ฑ: Moeum = .__ {
        didSet { char = Character(์ดˆ์„ฑ, ์ค‘์„ฑ, ์ข…์„ฑ) }
    }
    var ์ข…์„ฑ: Badchim = .__ {
        didSet { char = Character(์ดˆ์„ฑ, ์ค‘์„ฑ, ์ข…์„ฑ) }
    }
    var ๋ฐ›์นจ: Badchim {
        ์ข…์„ฑ
    }
}

extension Geulzza: Equatable {
    public static func == (lhs: Geulzza, rhs: Geulzza) -> Bool {
        lhs.char == rhs.char
    }
    public static func == (lhs: Geulzza, rhs: Character) -> Bool {
        lhs.char == rhs
    }
    public static func == (lhs: Character, rhs: Geulzza) -> Bool {
        lhs == rhs.char 
    }
}

it's made of only one file, but here is the core of this library anyway.
๊ณ ์ž‘ ํŒŒ์ผ ํ•˜๋‚˜๋กœ ๋งŒ๋“ค์–ด์กŒ๊ธด ํ•ด๋„, ์–ด์จŒ๋“  ์ด๊ฒŒ ๋ณธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ํ•ต์‹ฌ์ž…๋‹ˆ๋‹ค.

integration

SPM

just use Swift Package Manager to install geulzza by adding this repository.
์Šค์œ„ํ”„ํŠธ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋ฅผ ์‚ฌ์šฉํ•ด ์ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์œผ๋กœ geulzza๋ฅผ ์„ค์น˜ํ•˜์„ธ์š”.

copy && paste

or just copy and paste geulzza.swift to your project.
์•„๋‹ˆ๋ฉด geulzza.swift ํŒŒ์ผ์„ ๋ณต์‚ฌํ•ด ๋‹น์‹ ์˜ ํ”„๋กœ์ ํŠธ์— ๋ถ™์—ฌ๋„ฃ์œผ์„ธ์š”.

support

support me through kakaopay, so i can at least eat.
even a dime helps a lot, for ten of them become a great meal.
์นด์นด์˜คํŽ˜์ด๋กœ ํ›„์›ํ•ด ์ œ๊ฐ€ ๋ฐฅ์€ ๋จน๊ณ  ๋‹ค๋‹ˆ๋„๋ก ๋„์™€์ฃผ์„ธ์š”.
๋ฐฑ ์›์กฐ์ฐจ๋„ ์—ด ๋ฒˆ๋งŒ ๋ชจ์ด๋ฉด ํ›Œ๋ฅญํ•œ ํ•œ ๋ผ๊ฐ€ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฌด์ฒ™ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

kakaopay qr code

GitHub

link
Stars: 4
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics