// Combines both gbkUrlEscapedEntityCallback and GBK character substitution. static void gbkUrlEscapedEntityCallack(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err) { if (reason == UCNV_UNASSIGNED) { if (UChar outChar = fallbackForGBK(codePoint)) { const UChar* source = &outChar; *err = U_ZERO_ERROR; ucnv_cbFromUWriteUChars(fromUArgs, &source, source + 1, 0, err); return; } urlEscapedEntityCallback(context, fromUArgs, codeUnits, length, codePoint, reason, err); return; } UCNV_FROM_U_CALLBACK_ESCAPE(context, fromUArgs, codeUnits, length, codePoint, reason, err); }
// Generic helper for writing escaped entities using the specfied // UnencodableHandling. static void formatEscapedEntityCallback(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err, UnencodableHandling handling) { if (reason == UCNV_UNASSIGNED) { *err = U_ZERO_ERROR; UnencodableReplacementArray entity; int entityLen = TextCodec::getUnencodableReplacement(codePoint, handling, entity); ucnv_cbFromUWriteBytes(fromUArgs, entity, entityLen, 0, err); } else { UCNV_FROM_U_CALLBACK_ESCAPE(context, fromUArgs, codeUnits, length, codePoint, reason, err); } }