asKoreanWithUnits method
String
asKoreanWithUnits(
{ - bool ignoreIl = false,
})
Implementation
String asKoreanWithUnits({bool ignoreIl = false}) {
assert(this >= 0);
String value = toString().reversed;
List<String> resultList = [];
for (int i = 0; i < value.length; i++) {
String text = '';
int index = int.parse(value[i]), s = i ~/ 4 * 4;
var range = IntRange(s, min(s + 4, value.length));
String fourDigits = value.substring(range.start, range.end);
if (this == 0 || index > 0) text = _unitsLessThanSip[index] + _unitsLessThanMan[i % 4];
if (i % 4 == 0 && int.parse(fourDigits).toBool) text += _unitsMoreThanMan[i ~/ 4];
resultList.insert(0, text);
}
String result = '${resultList.join('').replaceAll(' ', '')} ';
if (!ignoreIl) return result.trim();
String pattern = '${_unitsLessThanSip[1]}(?![$_unitsMoreThanMan])';
return result.replaceAllMapped(RegExp(pattern), (_) => '').trim();
}