UNPKG

ice.fo.utils

Version:

16 lines (13 loc) 421 B
import getKoreanCharacters from './getKoreanCharacters'; import getNonKoreanCharacters from './getNonKoreanCharacters'; /** * Korean is 2 bytes each character * Else 1 byte * * @param {*} text */ export default function countSimpleStringBytes(text) { const koreanChars = getKoreanCharacters(text); const nonKoreanChars = getNonKoreanCharacters(text); return koreanChars.length * 2 + nonKoreanChars.length; }