Klaus Demo nginx / a089857
rename ngx_utf_...() to ngx_utf8_...() Igor Sysoev 13 years ago
4 changed file(s) with 18 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
951951
952952
953953 /*
954 * ngx_utf_decode() decodes two and more bytes UTF sequences only
954 * ngx_utf8_decode() decodes two and more bytes UTF sequences only
955955 * the return values:
956956 * 0x80 - 0x10ffff valid character
957957 * 0x110000 - 0xfffffffd invalid sequence
960960 */
961961
962962 uint32_t
963 ngx_utf_decode(u_char **p, size_t n)
963 ngx_utf8_decode(u_char **p, size_t n)
964964 {
965965 size_t len;
966966 uint32_t u, i, valid;
10171017
10181018
10191019 size_t
1020 ngx_utf_length(u_char *p, size_t n)
1020 ngx_utf8_length(u_char *p, size_t n)
10211021 {
10221022 u_char c, *last;
10231023 size_t len;
10331033 continue;
10341034 }
10351035
1036 if (ngx_utf_decode(&p, n) > 0x10ffff) {
1037 /* invalid utf */
1036 if (ngx_utf8_decode(&p, n) > 0x10ffff) {
1037 /* invalid UTF-8 */
10381038 return n;
10391039 }
10401040 }
10441044
10451045
10461046 u_char *
1047 ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n, size_t len)
1047 ngx_utf8_cpystrn(u_char *dst, u_char *src, size_t n, size_t len)
10481048 {
10491049 u_char c, *next;
10501050
10721072
10731073 next = src;
10741074
1075 if (ngx_utf_decode(&next, len) > 0x10ffff) {
1076 /* invalid utf */
1075 if (ngx_utf8_decode(&next, len) > 0x10ffff) {
1076 /* invalid UTF-8 */
10771077 break;
10781078 }
10791079
150150 void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src);
151151 ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src);
152152
153 uint32_t ngx_utf_decode(u_char **p, size_t n);
154 size_t ngx_utf_length(u_char *p, size_t n);
155 u_char *ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n, size_t len);
153 uint32_t ngx_utf8_decode(u_char **p, size_t n);
154 size_t ngx_utf8_length(u_char *p, size_t n);
155 u_char *ngx_utf8_cpystrn(u_char *dst, u_char *src, size_t n, size_t len);
156156
157157
158158 #define NGX_ESCAPE_URI 0
328328 NGX_ESCAPE_HTML);
329329
330330 if (r->utf8) {
331 entry->utf_len = ngx_utf_length(entry->name.data, entry->name.len);
331 entry->utf_len = ngx_utf8_length(entry->name.data, entry->name.len);
332332 } else {
333333 entry->utf_len = len;
334334 }
419419 utf_len = NGX_HTTP_AUTOINDEX_NAME_LEN + 1;
420420 }
421421
422 b->last = ngx_utf_cpystrn(b->last, entry[i].name.data,
423 utf_len, entry[i].name.len + 1);
422 b->last = ngx_utf8_cpystrn(b->last, entry[i].name.data,
423 utf_len, entry[i].name.len + 1);
424424 last = b->last;
425425
426426 } else {
641641 size = buf->last - src;
642642
643643 saved = src;
644 n = ngx_utf_decode(&saved, size);
644 n = ngx_utf8_decode(&saved, size);
645645
646646 if (n == 0xfffffffe) {
647647 /* incomplete UTF-8 symbol */
709709 }
710710
711711 saved = ctx->saved;
712 n = ngx_utf_decode(&saved, i);
712 n = ngx_utf8_decode(&saved, i);
713713
714714 c = '\0';
715715
817817
818818 len = buf->last - src;
819819
820 n = ngx_utf_decode(&src, len);
820 n = ngx_utf8_decode(&src, len);
821821
822822 if (n < 0x10000) {
823823
12691269
12701270 p = &table->src2dst[src * NGX_UTF_LEN] + 1;
12711271
1272 n = ngx_utf_decode(&p, i);
1272 n = ngx_utf8_decode(&p, i);
12731273
12741274 if (n > 0xffff) {
12751275 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,