Go to the source code of this file.
|
| static int | pg_get_utf8_id (void) |
| |
| static char32_t | utf8_to_unicode (const unsigned char *c) |
| |
| static int | utf_charcheck (const unsigned char *c) |
| |
| static void | mb_utf_validate (unsigned char *pwcs) |
| |
| int | pg_wcswidth (const char *pwcs, size_t len, int encoding) |
| |
| void | pg_wcssize (const unsigned char *pwcs, size_t len, int encoding, int *result_width, int *result_height, int *result_format_size) |
| |
| void | pg_wcsformat (const unsigned char *pwcs, size_t len, int encoding, struct lineptr *lines, int count) |
| |
| unsigned char * | mbvalidate (unsigned char *pwcs, int encoding) |
| |
◆ PG_UTF8
◆ pg_wchar
◆ mb_utf_validate()
Definition at line 136 of file mbprint.c.
137{
138 unsigned char *p =
pwcs;
139
141 {
143
145 {
147 {
149
152 }
153 else
154 {
157 }
158 }
159 else
160
162 }
164 *p = '\0';
165}
static int utf_charcheck(const unsigned char *c)
References fb(), i, len, and utf_charcheck().
Referenced by mbvalidate().
◆ mbvalidate()
◆ pg_get_utf8_id()
◆ pg_wcsformat()
Definition at line 294 of file mbprint.c.
296{
297 int w,
300 unsigned char *ptr = lines->
ptr;
301
303 {
306 break;
308
310 {
312 {
313 *ptr++ = '\0';
316 lines++;
317 count--;
318 if (count <= 0)
320
321
323 }
324 else if (*
pwcs ==
'\r')
325 {
326 strcpy((
char *) ptr,
"\\r");
328 ptr += 2;
329 }
330 else if (*
pwcs ==
'\t')
331 {
332 do
333 {
334 *ptr++ = ' ';
337 }
338 else if (w < 0)
339 {
342 ptr += 4;
343 }
344 else
345 {
348 }
349 }
350 else if (w < 0)
351 {
354 else
355 {
356
357
358
359
360
361 sprintf((
char *) ptr,
"\\u????");
362 }
363 ptr += 6;
365 }
366 else
367 {
369
373 }
375 }
377 *ptr++ = '\0';
378
379 if (count <= 0)
381
382 (lines + 1)->ptr =
NULL;
383}
int PQmblen(const char *s, int encoding)
int PQdsplen(const char *s, int encoding)
static char32_t utf8_to_unicode(const unsigned char *c)
References encoding, fb(), i, len, PG_UTF8, PQdsplen(), PQmblen(), lineptr::ptr, sprintf, utf8_to_unicode(), and lineptr::width.
Referenced by print_aligned_text(), and print_aligned_vertical().
◆ pg_wcssize()
Definition at line 211 of file mbprint.c.
213{
214 int w,
217 int width = 0;
218 int height = 1;
220
222 {
225 break;
227
229 {
231 {
235 height += 1;
237 }
238 else if (*
pwcs ==
'\r')
239 {
242 }
243 else if (*
pwcs ==
'\t')
244 {
245 do
246 {
250 }
251 else if (w < 0)
252 {
255 }
256 else
257 {
260 }
261 }
262 else if (w < 0)
263 {
266 }
267 else
268 {
271 }
273 }
277
278
285}
References encoding, fb(), len, PQdsplen(), and PQmblen().
Referenced by print_aligned_text(), and print_aligned_vertical().
◆ pg_wcswidth()
◆ utf8_to_unicode()
Definition at line 53 of file mbprint.c.
54{
56 return (
char32_t)
c[0];
57 else if ((*
c & 0xe0) == 0xc0)
58 return (
char32_t) (((
c[0] & 0x1f) << 6) |
60 else if ((*
c & 0xf0) == 0xe0)
61 return (
char32_t) (((
c[0] & 0x0f) << 12) |
62 ((
c[1] & 0x3f) << 6) |
64 else if ((*
c & 0xf8) == 0xf0)
65 return (
char32_t) (((
c[0] & 0x07) << 18) |
66 ((
c[1] & 0x3f) << 12) |
67 ((
c[2] & 0x3f) << 6) |
69 else
70
71 return 0xffffffff;
72}
Referenced by check_final_sigma(), convert_case(), initcap_wbnext(), initcap_wbnext(), pg_saslprep(), pg_utf_dsplen(), pg_wcsformat(), read_char(), unicode_assigned(), unicode_is_normalized(), and unicode_normalize_func().
◆ utf_charcheck()
Definition at line 82 of file mbprint.c.
83{
85 return 1;
86 else if ((*
c & 0xe0) == 0xc0)
87 {
88
89 if (((
c[1] & 0xc0) == 0x80) && ((
c[0] & 0x1f) > 0x01))
90 return 2;
91 return -1;
92 }
93 else if ((*
c & 0xf0) == 0xe0)
94 {
95
96 if (((
c[1] & 0xc0) == 0x80) &&
97 (((
c[0] & 0x0f) != 0x00) || ((
c[1] & 0x20) == 0x20)) &&
98 ((
c[2] & 0xc0) == 0x80))
99 {
101 int yx = ((
c[1] & 0x3f) << 6) | (
c[0] & 0x3f);
103
104
105 if (((z == 0x0f) &&
106 (((
yx & 0xffe) == 0xffe) ||
107 (((
yx & 0xf80) == 0xd80) && (
lx >= 0x30) && (
lx <= 0x4f)))) ||
108 ((z == 0x0d) && ((
yx & 0xb00) == 0x800)))
109 return -1;
110 return 3;
111 }
112 return -1;
113 }
114 else if ((*
c & 0xf8) == 0xf0)
115 {
116 int u = ((
c[0] & 0x07) << 2) | ((
c[1] & 0x30) >> 4);
117
118
119 if (((
c[1] & 0xc0) == 0x80) &&
120 (u > 0x00) && (u <= 0x10) &&
121 ((
c[2] & 0xc0) == 0x80) && ((
c[3] & 0xc0) == 0x80))
122 {
123
124 if (((
c[1] & 0x0f) == 0x0f) && ((
c[2] & 0x3f) == 0x3f) &&
125 ((
c[3] & 0x3e) == 0x3e))
126 return -1;
127 return 4;
128 }
129 return -1;
130 }
131 return -1;
132}
References fb().
Referenced by mb_utf_validate().