# Test Emoji separate to avoid problems with older versions of R that may not
# support them in the same way

# can't lest stuff above BMP output as windows can get messed up by that,
# otherwise we wouldn't have to use nchar below

nchar(substr2_ctl(flags, 1, 2, type = "width"))

flags <- paste0(rep("🇦🇿🇧🇾🇨🇽", 2), collapse = "")

strwrap2_ctl(flags, 6, wrap.always = TRUE, pad.end = " ", carry = "\033[44m")

strwrap2_ctl(flags, 7, wrap.always = TRUE, pad.end = " ", carry = "\033[44m")

strwrap2_ctl(flags.1, 7, wrap.always = TRUE, pad.end = " ", carry = "\033[44m")

substr2_ctl(flags, 1, 1, type = "width")

substr2_ctl(flags, 1, 1, type = "width", round = "stop")

substr2_ctl(flags, 1, 2, type = "width", round = "neither")

substr2_ctl(flags, 2, 3, type = "width", round = "stop")

substr2_ctl(flags, 2, 3, type = "width", round = "start")

substr2_ctl(flags, 2, 3, type = "width", round = "both")

substr2_ctl(flags, 2, 3, type = "width", round = "neither")

nchar_ctl(c(emo.0, emo.1, emo.2), type = "width")

nchar_ctl(c(emo.0, emo.1, emo.2), type = "graphemes")

substr2_ctl(emo.0, 1, 1, type = "width")

substr2_ctl(emo.0, 1, 1, type = "width", round = "stop")

substr2_ctl(emo.0, 1, 2, type = "width", round = "stop")

substr2_ctl(emo.0, 2, 3, type = "width", round = "stop")

substr2_ctl(emo.0, 2, 3, type = "width", round = "start")

substr2_ctl(emo.0, 2, 3, type = "width", round = "both")

substr2_ctl(emo.0, 2, 3, type = "width", round = "neither")

substr2_ctl(emo.1, 1, 3, type = "width")

substr2_ctl(emo.1, 1, 3, type = "width", round = "stop")

substr2_ctl(emo.1, 3, 5, type = "width")

substr2_ctl(emo.1, 4, 5, type = "width")

once upon a time 🇦🇿🇧🇾🇨🇽🇦🇿🇧🇾🇨🇽 there was a humpty 👶🏽👨🏿👮🏿👶🏽👨🏿👮🏿 dumpty A_👨🏾‍🦳_B on the wall 👨🏾‍🦳and he had 👩🏽‍✈️ a 👨‍👩‍👧‍👦 big fall 👩🏽‍✈️ oh no 👨🏾‍🦳
once upon a time 🇦🇿🇧🇾🇨🇽🇦🇿🇧🇾🇨🇽 there was a humpty 👶🏽👨🏿👮🏿👶🏽👨🏿👮🏿 dumpty A_👨🏾‍🦳_B on the wall 👨🏾‍🦳and he had 👩🏽‍✈️ a 👨‍👩‍👧‍👦 big fall 👩🏽‍✈️ oh no 👨🏾‍🦳

emo.big <- rep(sprintf(paste0("once upon a time %s there was a humpty %s%s dumpty %s on the wall %s", 
    "and he had %s a %s big fall %s oh no %s"), flags, emo.0, 
    emo.0, emo.1, emo.2, emo.3, emo.4, emo.3, emo.2), 2)