按用户感知字符读取指定位置的字符。
原生 charAt() / value[index] 都按 UTF-16 code unit 取值,可能只取到半个 surrogate pair, 也会把国旗、肤色 emoji、ZWJ 序列拆开。本函数的 index 对应 grapheme cluster 下标。
charAt()
value[index]
被读取的字符串。
用户感知字符下标。
指定位置的用户感知字符;越界、负数或非有限数字时返回空字符串。
0.2.0
getUnicodeCharacterAt('A😀🇯🇵👍🏽B', 2) // '🇯🇵'getUnicodeCharacterAt('A😀🇯🇵👍🏽B', -1) // '' Copy
getUnicodeCharacterAt('A😀🇯🇵👍🏽B', 2) // '🇯🇵'getUnicodeCharacterAt('A😀🇯🇵👍🏽B', -1) // ''
按用户感知字符读取指定位置的字符。
原生
charAt()/value[index]都按 UTF-16 code unit 取值,可能只取到半个 surrogate pair, 也会把国旗、肤色 emoji、ZWJ 序列拆开。本函数的 index 对应 grapheme cluster 下标。