diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 441c2b32763a96..30436a6f7a4593 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -642,13 +642,13 @@ int32_t ToUnicode(MaybeStackBuffer* buf, int32_t ToASCII(MaybeStackBuffer* buf, const char* input, size_t length, - enum idna_mode mode) { + idna_mode mode) { UErrorCode status = U_ZERO_ERROR; uint32_t options = // CheckHyphens = false; handled later UIDNA_CHECK_BIDI | // CheckBidi = true UIDNA_CHECK_CONTEXTJ | // CheckJoiners = true UIDNA_NONTRANSITIONAL_TO_ASCII; // Nontransitional_Processing - if (mode == IDNA_STRICT) { + if (mode == idna_mode::IDNA_STRICT) { options |= UIDNA_USE_STD3_RULES; // UseSTD3ASCIIRules = beStrict // VerifyDnsLength = beStrict; // handled later @@ -696,14 +696,15 @@ int32_t ToASCII(MaybeStackBuffer* buf, info.errors &= ~UIDNA_ERROR_LEADING_HYPHEN; info.errors &= ~UIDNA_ERROR_TRAILING_HYPHEN; - if (mode != IDNA_STRICT) { + if (mode != idna_mode::IDNA_STRICT) { // VerifyDnsLength = beStrict info.errors &= ~UIDNA_ERROR_EMPTY_LABEL; info.errors &= ~UIDNA_ERROR_LABEL_TOO_LONG; info.errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG; } - if (U_FAILURE(status) || (mode != IDNA_LENIENT && info.errors != 0)) { + if (U_FAILURE(status) || + (mode != idna_mode::IDNA_LENIENT && info.errors != 0)) { len = -1; buf->SetLength(0); } else { @@ -741,7 +742,7 @@ static void ToASCII(const FunctionCallbackInfo& args) { Utf8Value val(env->isolate(), args[0]); // optional arg bool lenient = args[1]->BooleanValue(env->isolate()); - enum idna_mode mode = lenient ? IDNA_LENIENT : IDNA_DEFAULT; + idna_mode mode = lenient ? idna_mode::IDNA_LENIENT : idna_mode::IDNA_DEFAULT; MaybeStackBuffer buf; int32_t len = ToASCII(&buf, *val, val.length(), mode); diff --git a/src/node_i18n.h b/src/node_i18n.h index 1e9f13ebc93f02..33001383d5402c 100644 --- a/src/node_i18n.h +++ b/src/node_i18n.h @@ -42,7 +42,7 @@ bool InitializeICUDirectory(const std::string& path); void SetDefaultTimeZone(const char* tzid); -enum idna_mode { +enum class idna_mode { // Default mode for maximum compatibility. IDNA_DEFAULT, // Ignore all errors in IDNA conversion, if possible. @@ -58,7 +58,7 @@ enum idna_mode { int32_t ToASCII(MaybeStackBuffer* buf, const char* input, size_t length, - enum idna_mode mode = IDNA_DEFAULT); + idna_mode mode = idna_mode::IDNA_DEFAULT); // Implements the WHATWG URL Standard "domain to Unicode" algorithm. // https://url.spec.whatwg.org/#concept-domain-to-unicode