I've found that certain characters (surrogates) when passed through $regsubex do not combine as they should.
This should resolve the characters and place them next to each other to display a '10' inside a box. $replace works fine. $regsubex corrupts the string.
Code:
//echo -ag $json.unescape(\ud83d\udd1f)
//echo -ag $regsubex(aa,/(a)/gu,$chr($gettok(55357 56607,\n,32))) vs $replace(ab,a,$chr(55357),b,$chr(56607))
Code:
alias json.unescape {
return $regsubex($1-,/\\(?:u(....)|(.))/gu,$escape.map(\t))
}
alias -l escape.map {
if ($1 isalpha) return $chr(160)
if ($1 !isalnum) return $1
if ($base($1,16,10) > 32) return $chr($v1)
return $chr(160)
}