return NULL;
}
- utf = 0x10000 + ((utf - 0xd800) << 10) + (utf_low - 0xdc00);
+ utf = njs_string_surrogate_pair(utf, utf_low);
}
s = nxt_utf8_encode(s, utf);
src++;
}
- /* Surrogate pair. */
-
if (cp_pair != 0) {
- cp = 0x10000 + ((cp_pair - 0xd800) << 10) + (cp - 0xdc00);
+ cp = njs_string_surrogate_pair(cp_pair, cp);
cp_pair = 0;
} else if (cp >= 0xd800 && cp <= 0xdfff) {
}
}
- /* Surrogate pair. */
-
if (cp_pair != 0) {
if (nxt_slow_path(cp < 0xdc00 || cp > 0xdfff)) {
goto invalid_pair;
}
- cp = 0x10000 + ((cp_pair - 0xd800) << 10) + (cp - 0xdc00);
+ cp = njs_string_surrogate_pair(cp_pair, cp);
cp_pair = 0;
} else if (cp >= 0xd800 && cp <= 0xdfff) {
/* The maximum signed int32_t. */
#define NJS_STRING_MAX_LENGTH 0x7fffffff
+/* Converting surrogate pair to code point. */
+#define njs_string_surrogate_pair(high, low) \
+ (0x10000 + ((high - 0xd800) << 10) + (low - 0xdc00))
+
/*
* NJS_STRING_MAP_STRIDE should be power of two to use shift and binary
* AND operations instead of division and remainder operations but no