* 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 * Find length, in UChars, of given string if converted to UChar string. */
| 1024 | * Find length, in UChars, of given string if converted to UChar string. |
| 1025 | */ |
| 1026 | static size_t |
| 1027 | uchar_length(UConverter *converter, const char *str, int32_t len) |
| 1028 | { |
| 1029 | UErrorCode status = U_ZERO_ERROR; |
| 1030 | int32_t ulen; |
| 1031 | |
| 1032 | ulen = ucnv_toUChars(converter, NULL, 0, str, len, &status); |
| 1033 | if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) |
| 1034 | { |
| 1035 | ereport(ERROR, |
| 1036 | (errmsg("%s failed: %s", "ucnv_toUChars", u_errorName(status)))); |
| 1037 | } |
| 1038 | return ulen; |
| 1039 | } |
| 1040 | |
| 1041 | |
| 1042 | /* |