* 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 * Convert the given source string into a UChar string, stored in dest, and * return the length (in UChars). */
| 1046 | * return the length (in UChars). |
| 1047 | */ |
| 1048 | static int32_t |
| 1049 | uchar_convert(UConverter *converter, UChar *dest, int32_t destlen, |
| 1050 | const char *src, int32_t srclen) |
| 1051 | { |
| 1052 | UErrorCode status = U_ZERO_ERROR; |
| 1053 | int32_t ulen; |
| 1054 | |
| 1055 | status = U_ZERO_ERROR; |
| 1056 | ulen = ucnv_toUChars(converter, dest, destlen, src, srclen, &status); |
| 1057 | if (U_FAILURE(status)) |
| 1058 | { |
| 1059 | ereport(ERROR, |
| 1060 | (errmsg("%s failed: %s", "ucnv_toUChars", u_errorName(status)))); |
| 1061 | } |
| 1062 | return ulen; |
| 1063 | } |
| 1064 | |
| 1065 | |
| 1066 | /* |