MCPcopy Create free account
hub / github.com/documentdb/documentdb / init_icu_converter

Function init_icu_converter

pg_documentdb_core/src/collation/collation.c:988–1018  ·  view source on GitHub ↗

* Ported from pg_locale.c in Postgres 17: * See https://github.com/postgres/postgres/blob/REL_17_STABLE/src/backend/utils/adt/pg_locale.c#L2758 * Initialuze the default ICU converter for the database encoding. */

Source from the content-addressed store, hash-verified

986 * Initialuze the default ICU converter for the database encoding.
987 */
988static void
989init_icu_converter(void)
990{
991 const char *icu_encoding_name;
992 UErrorCode status;
993 UConverter *conv;
994
995 if (icu_converter)
996 {
997 return; /* already done */
998 }
999 icu_encoding_name = get_encoding_name_for_icu(GetDatabaseEncoding());
1000 if (!icu_encoding_name)
1001 {
1002 ereport(ERROR,
1003 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1004 errmsg("encoding \"%s\" not supported by ICU",
1005 pg_encoding_to_char(GetDatabaseEncoding()))));
1006 }
1007
1008 status = U_ZERO_ERROR;
1009 conv = ucnv_open(icu_encoding_name, &status);
1010 if (U_FAILURE(status))
1011 {
1012 ereport(ERROR,
1013 (errmsg("could not open ICU converter for encoding \"%s\": %s",
1014 icu_encoding_name, u_errorName(status))));
1015 }
1016
1017 icu_converter = conv;
1018}
1019
1020
1021/*

Callers 1

icu_to_uchar_coreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected