bool isSurrogate(String str, int pos) { return 0xd800 <= str.codeUnitAt(pos) && str.codeUnitAt(pos) <= 0xdbff && 0xdc00 <= str.codeUnitAt(pos + 1) && str.codeUnitAt(pos + 1) <= 0xdfff; }