+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2007-2014, International Business Machines Corporation and
#include "unicode/ustring.h"
#include "unicode/putil.h"
#include "unicode/simpletz.h"
-
+#include "unicode/strenum.h"
#include "umutex.h"
#include "uvector.h"
#include "cmemory.h"
#include "uresimp.h"
#include "uhash.h"
#include "olsontz.h"
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+#include "uinvchar.h"
static UMutex gZoneMetaLock = U_MUTEX_INITIALIZER;
tzid.extract(utzid, ZID_KEY_MAX + 1, tmpStatus);
U_ASSERT(tmpStatus == U_ZERO_ERROR); // we checked the length of tzid already
+ if (!uprv_isInvariantUString(utzid, -1)) {
+ // All of known tz IDs are only containing ASCII invariant characters.
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return NULL;
+ }
+
// Check if it was already cached
umtx_lock(&gZoneMetaLock);
{
// If not, resolve CLDR canonical ID with resource data
UBool isInputCanonical = FALSE;
char id[ZID_KEY_MAX + 1];
- tzid.extract(0, 0x7fffffff, id, LENGTHOF(id), US_INV);
+ tzid.extract(0, 0x7fffffff, id, UPRV_LENGTHOF(id), US_INV);
// replace '/' with ':'
char *p = id;