* 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 a string in the database encoding into a string of UChars. * * The source string at buff is of length nbytes * (it needn't be nul-terminated) * * *buff_uchar receives a pointer to the palloc'd result string, and * the function's result is
| 1078 | * result length instead. |
| 1079 | */ |
| 1080 | static int32_t |
| 1081 | icu_to_uchar_core(UChar **buff_uchar, const char *buff, size_t nbytes) |
| 1082 | { |
| 1083 | int32_t len_uchar; |
| 1084 | |
| 1085 | init_icu_converter(); |
| 1086 | |
| 1087 | len_uchar = uchar_length(icu_converter, buff, nbytes); |
| 1088 | |
| 1089 | *buff_uchar = palloc((len_uchar + 1) * sizeof(**buff_uchar)); |
| 1090 | len_uchar = uchar_convert(icu_converter, |
| 1091 | *buff_uchar, len_uchar + 1, buff, nbytes); |
| 1092 | |
| 1093 | return len_uchar; |
| 1094 | } |
no test coverage detected