1048{
1049 char32_t *input_chars = NULL;
1050 char32_t *output_chars = NULL;
1051 int input_size;
1052 char *result;
1053 int result_size;
1054 int count;
1056 bool contains_RandALCat;
1057 const unsigned char *p;
1058 unsigned char *outp;
1059 char32_t *wp;
1060
1061
1063
1064
1065
1066
1067
1069 {
1072 goto oom;
1074 }
1075
1076
1077
1078
1079
1080
1082 if (input_size < 0)
1085 goto oom;
1086
1087 input_chars =
ALLOC((input_size + 1) *
sizeof(
char32_t));
1088 if (!input_chars)
1089 goto oom;
1090
1091 p = (
const unsigned char *)
input;
1092 for (
i = 0;
i < input_size;
i++)
1093 {
1096 }
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108 count = 0;
1109 for (
i = 0;
i < input_size;
i++)
1110 {
1111 char32_t code = input_chars[
i];
1112
1114 input_chars[count++] = 0x0020;
1116 {
1117
1118 }
1119 else
1120 input_chars[count++] = code;
1121 }
1122 input_chars[count] = (
char32_t)
'\0';
1123 input_size = count;
1124
1125 if (input_size == 0)
1126 goto prohibited;
1127
1128
1129
1130
1131
1133 if (!output_chars)
1134 goto oom;
1135
1136
1137
1138
1139
1140 for (
i = 0;
i < input_size;
i++)
1141 {
1142 char32_t code = input_chars[
i];
1143
1145 goto prohibited;
1147 goto prohibited;
1148 }
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171 contains_RandALCat = false;
1172 for (
i = 0;
i < input_size;
i++)
1173 {
1174 char32_t code = input_chars[
i];
1175
1177 {
1178 contains_RandALCat = true;
1179 break;
1180 }
1181 }
1182
1183 if (contains_RandALCat)
1184 {
1185 char32_t first = input_chars[0];
1186 char32_t last = input_chars[input_size - 1];
1187
1188 for (
i = 0;
i < input_size;
i++)
1189 {
1190 char32_t code = input_chars[
i];
1191
1193 goto prohibited;
1194 }
1195
1198 goto prohibited;
1199 }
1200
1201
1202
1203
1204 result_size = 0;
1205 for (wp = output_chars; *wp; wp++)
1206 {
1207 unsigned char buf[4];
1208
1211 }
1212
1213 result =
ALLOC(result_size + 1);
1214 if (!result)
1215 goto oom;
1216
1217
1218
1219
1220
1221 outp = (unsigned char *) result;
1222 for (wp = output_chars; *wp; wp++)
1223 {
1226 }
1227 Assert((
char *) outp == result + result_size);
1228 *outp = '\0';
1229
1232
1235
1236prohibited:
1237 if (input_chars)
1239 if (output_chars)
1241
1243
1244oom:
1245 if (input_chars)
1247 if (output_chars)
1249
1251}
Assert(PointerIsAligned(start, uint64))
static char32_t utf8_to_unicode(const unsigned char *c)
static char buf[DEFAULT_XLOG_SEG_SIZE]
static unsigned char * unicode_to_utf8(char32_t c, unsigned char *utf8string)
static const char32_t LCat_codepoint_ranges[]
static const char32_t prohibited_output_ranges[]
static const char32_t commonly_mapped_to_nothing_ranges[]
#define IS_CODE_IN_TABLE(code, map)
static const char32_t unassigned_codepoint_ranges[]
static const char32_t RandALCat_codepoint_ranges[]
static int pg_utf8_string_len(const char *source)
static const char32_t non_ascii_space_ranges[]
bool pg_is_ascii(const char *str)
char32_t * unicode_normalize(UnicodeNormalizationForm form, const char32_t *input)