-#ifdef PHP_HTTP_HAVE_WCHAR
-static zend_bool cs_is_utf8(char **lc_ctype)
-{
-#if HAVE_NL_LANGINFO
- if (strcmp("UTF-8", nl_langinfo(CODESET))) {
- *lc_ctype = setlocale(LC_CTYPE, NULL);
- return 0;
- }
- return 1;
-#else
- *lc_ctype = setlocale(LC_CTYPE, NULL);
-
- if (*lc_ctype) {
- char *cs;
-
- if ((cs = strstr(*lc_ctype, ".utf")) || (cs = strstr(*lc_ctype, ".UTF"))) {
- if (cs[4] == '-') {
- ++cs;
- }
- if (cs[4] == '8' && (cs[5] == '\0' || cs[5] == '@')) {
- return 1;
- }
- }
- return 0;
- }
-#endif
-}
-
-static const unsigned char utf8mblen[256] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
- 4,4,4,4,4,4,4,4,5,5,5,5,6,6,6,6
-};
-static const unsigned char utf8mask[] = {
- 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01
-};
-
-static size_t utf8towc(wchar_t *wc, const unsigned char *uc, size_t len)