func DisplayWidth(str string) int {
	width := 0
	runes := []rune(str)
	for i := 0; i < len(runes); i ++ {
		r := runes[i]
		if isZeroWidth(r) {
			continue
		}
		if i > 0 && runes[i-1] == ZWJ {
			// ZWJ effectively "suppresses" the next character
			continue
		}
		if i > 0 && isRegionalIndicator(r) && isRegionalIndicator(runes[i-1]) {
			// only count first flag character in a sequence
			continue
		}
		if i > 0 && isSkinToneModifier(r) && IsEmoji(runes[i-1]) {
			// don't count skin tone modifier when it's modifying something
			continue
		}
		width += 1
	}
	return width
}
// DisplayWidth attempts to guess at the display width of a string containing
// emoji, taking into account variation selectors (0xFE00-0xFE0F), zero-width
// joins (0x200D), combining diacritical marks (0x20d0-0x20ff), flags,
// and skin tone modifiers.
DisplayWidth attempts to guess at the display width of a string containing
emoji, taking into account variation selectors (0xFE00-0xFE0F), zero-width
joins (0x200D), combining diacritical marks (0x20d0-0x20ff), flags,
and skin tone modifiers.
// DisplayWidth attempts to guess at the display width of a string containing // emoji taking into account variation selectors ( 0xFE00 - 0xFE0F ) zero - width // joins ( 0x200D ) combining diacritical marks ( 0x20d0 - 0x20ff ) flags // and skin tone modifiers .
func DisplayWidth(str string) int {
	width := 0
	runes := []rune(str)
	for i := 0; i < len(runes); i ++ {
		r := runes[i]
		if isZeroWidth(r) {
			continue
		}
		if i > 0 && runes[i-1] == ZWJ {
			continue
		}
		if i > 0 && isRegionalIndicator(r) && isRegionalIndicator(runes[i-1]) {
			continue
		}
		if i > 0 && isSkinToneModifier(r) && IsEmoji(runes[i-1]) {
			continue
		}
		width += 1
	}
	return width
}
func DisplayWidth ( str string ) int { width := 0 runes := [ ] rune ( str ) for i := 0 ; i < len ( runes ) ; i ++ { r := runes [ i ] if isZeroWidth ( r ) { continue } if i > 0 && runes [ i - 1 ] == ZWJ { continue } if i > 0 && isRegionalIndicator ( r ) && isRegionalIndicator ( runes [ i - 1 ] ) { continue } if i > 0 && isSkinToneModifier ( r ) && IsEmoji ( runes [ i - 1 ] ) { continue } width += 1 } return width }
DisplayWidth attempts to guess at the display width of a string containing
emoji, taking into account variation selectors (0xFE00-0xFE0F), zero-width
joins (0x200D), combining diacritical marks (0x20d0-0x20ff), flags,
and skin tone modifiers.
DisplayWidth attempts to guess at the display width of a string containing emoji taking into account variation selectors ( 0xFE00 - 0xFE0F ) zero - width joins ( 0x200D ) combining diacritical marks ( 0x20d0 - 0x20ff ) flags and skin tone modifiers .
// ZWJ effectively "suppresses" the next character // only count first flag character in a sequence // don't count skin tone modifier when it's modifying something