hangul 0.7.0 copy "hangul: ^0.7.0" to clipboard
hangul: ^0.7.0 copied to clipboard

Work with korean hangul characters (한글). Validate characters, split syllables into jamo, merge jamos into syllables.

example/main.dart

import 'package:hangul/hangul.dart';

void main(List<String> arguments) {
  const wordToTransform = "하다";

  // ensure all characters are valid syllables
  wordToTransform.runes.forEach((char) {
    if (!isHangulSyllableCode(char)) {
      throw ArgumentError('Invalid Hangul syllable: $char');
    }
  });

  // convert each character to a HangulSyllable instance
  final List<HangulSyllable> syllables =
      wordToTransform.runes.map((e) => HangulSyllable.fromCharCode(e)).toList();

  // replace  the jung (vowel) of each word
  // 하다 will become 후두.
  syllables.forEach((syllable) {
    syllable.jung = 'ㅜ';
  });

  final newWord = syllables.join('');

  print('Word transformed:');
  print(newWord);

  // input hangul characters in the string
  final input = HangulInput(newWord);

  input.pushCharacter('ㄹ');
  input.pushCharacter('ㅡ');
  input.pushCharacter('ㄹ');

  print('String with added input:');
  print(input.text);

  input.backspace();
  input.backspace();
  input.pushCharacter('ㅏ');

  print('String with backspace and replaced input:');
  print(input.text);
}
13
likes
160
points
310
downloads

Publisher

verified publishersouf.fr

Weekly Downloads

Work with korean hangul characters (한글). Validate characters, split syllables into jamo, merge jamos into syllables.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on hangul