php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
codepage.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Anatol Belski <ab@php.net> |
14 +----------------------------------------------------------------------+
15*/
16
17#include <assert.h>
18
19#include "php.h"
20#include "SAPI.h"
21#ifdef _M_ARM64
22# include <arm_neon.h>
23#else
24# include <emmintrin.h>
25#endif // _M_ARM64
26
27#include "win32/console.h"
28
35
36#include "cp_enc_map.c"
37
38__forceinline static wchar_t *php_win32_cp_to_w_int(const char* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
39{/*{{{*/
40 wchar_t *ret;
41 int ret_len, tmp_len;
42
43 if (!in || in_len > (size_t)INT_MAX) {
44 SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
45 return NULL;
46 }
47 assert(in_len ? (in[in_len] == L'\0') : 1);
48
49 tmp_len = !in_len ? -1 : (int)in_len + 1;
50
51 ret_len = MultiByteToWideChar(cp, flags, in, tmp_len, NULL, 0);
52 if (ret_len == 0) {
53 SET_ERRNO_FROM_WIN32_CODE(GetLastError());
54 return NULL;
55 }
56
57 ret = malloc(ret_len * sizeof(wchar_t));
58 if (!ret) {
59 SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
60 return NULL;
61 }
62
63 tmp_len = MultiByteToWideChar(cp, flags, in, tmp_len, ret, ret_len);
64 if (tmp_len == 0) {
65 free(ret);
66 SET_ERRNO_FROM_WIN32_CODE(GetLastError());
67 return NULL;
68 }
69
70 assert(ret ? tmp_len == ret_len : 1);
71 assert(ret && !in_len ? wcslen(ret) == ret_len - 1 : 1);
72
73 ret[ret_len-1] = L'\0';
74
75 if (PHP_WIN32_CP_IGNORE_LEN_P != out_len) {
76 *out_len = ret_len - 1;
77 }
78
79 return ret;
80}/*}}}*/
81
82PW32CP wchar_t *php_win32_cp_conv_utf8_to_w(const char* in, size_t in_len, size_t *out_len)
83{/*{{{*/
84 return php_win32_cp_to_w_int(in, in_len, out_len, CP_UTF8, MB_ERR_INVALID_CHARS);
85}/*}}}*/
86
87PW32CP wchar_t *php_win32_cp_conv_cur_to_w(const char* in, size_t in_len, size_t *out_len)
88{/*{{{*/
89 wchar_t *ret;
90
91 ret = php_win32_cp_to_w_int(in, in_len, out_len, cur_cp->id, cur_cp->from_w_fl);
92
93 return ret;
94}/*}}}*/
95
96PW32CP wchar_t *php_win32_cp_conv_to_w(DWORD cp, DWORD flags, const char* in, size_t in_len, size_t *out_len)
97{/*{{{*/
98 return php_win32_cp_to_w_int(in, in_len, out_len, cp, flags);
99}/*}}}*/
100
101#define ASCII_FAIL_RETURN() \
102 if (PHP_WIN32_CP_IGNORE_LEN_P != out_len) { \
103 *out_len = 0; \
104 } \
105 return NULL;
106PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size_t *out_len)
107{/*{{{*/
108 wchar_t *ret, *ret_idx;
109 const char *idx = in, *end;
110 char ch_err = 0;
111
112#if PHP_DEBUG
113 size_t save_in_len = in_len;
114#endif
115
116 assert(in && in_len ? in[in_len] == '\0' : 1);
117
118 if (!in) {
119 SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
120 return NULL;
121 } else if (0 == in_len) {
122 /* Not binary safe. */
123 in_len = strlen(in);
124 }
125
126 end = in + in_len;
127
128 if (in_len > 15) {
129 const char *aidx = (const char *)ZEND_SLIDE_TO_ALIGNED16(in);
130
131 /* Process unaligned chunk. */
132 while (idx < aidx) {
133 ch_err |= *idx;
134 idx++;
135 }
136 if (ch_err & 0x80) {
138 }
139
140 /* Process aligned chunk. */
141#ifdef _M_ARM64
142 uint8x16_t ver_err = {0};
143 while (end - idx > 15) {
144 const uint8x16_t block = vld1q_u8((const void*)idx);
145 ver_err = vorrq_u8(ver_err, block);
146 idx += 16;
147 }
148 ver_err = vshrq_n_u8(ver_err, 7);
149 if (vmaxvq_u8(ver_err)) {
151 }
152#else
153 __m128i vec_err = _mm_setzero_si128();
154 while (end - idx > 15) {
155 const __m128i block = _mm_load_si128((__m128i *)idx);
156 vec_err = _mm_or_si128(vec_err, block);
157 idx += 16;
158 }
159 if (_mm_movemask_epi8(vec_err)) {
161 }
162#endif // _M_ARM64
163 }
164
165 /* Process the trailing part, or otherwise process string < 16 bytes. */
166 while (idx < end) {
167 ch_err |= *idx;
168 idx++;
169 }
170 if (ch_err & 0x80) {
172 }
173
174 ret = malloc((in_len+1)*sizeof(wchar_t));
175 if (!ret) {
176 SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
177 return NULL;
178 }
179
180 ret_idx = ret;
181 idx = in;
182
183 if (in_len > 15) {
184 const char *aidx = (const char *)ZEND_SLIDE_TO_ALIGNED16(in);
185
186 /* Process unaligned chunk. */
187 while (idx < aidx) {
188 *ret_idx++ = (wchar_t)*idx++;
189 }
190
191 /* Process aligned chunk. */
192 if (end - idx > 15) {
193#ifdef _M_ARM64
194 while (end - idx > 15) {
195 /*
196 vst2q_u8 below will store interlaced vector by 8bits, so this will be little endian wchar
197 at wrote time all windows arm64 is little endian
198 */
199 uint8x16x2_t vec = {/* .val = */{
200 vld1q_u8((const void*)idx),
201 {0},
202 }};
203
204 vst2q_u8((void*)ret_idx, vec);
205 idx += 16;
206 ret_idx += 16;
207 }
208#else
209 const __m128i mask = _mm_set1_epi32(0);
210 while (end - idx > 15) {
211 const __m128i block = _mm_load_si128((__m128i *)idx);
212
213 const __m128i lo = _mm_unpacklo_epi8(block, mask);
214 _mm_storeu_si128((__m128i *)ret_idx, lo);
215
216 ret_idx += 8;
217 const __m128i hi = _mm_unpackhi_epi8(block, mask);
218 _mm_storeu_si128((__m128i *)ret_idx, hi);
219
220 idx += 16;
221 ret_idx += 8;
222 }
223#endif // _M_ARM64
224 }
225 }
226
227 /* Process the trailing part, or otherwise process string < 16 bytes. */
228 while (idx < end) {
229 *ret_idx++ = (wchar_t)*idx++;
230 }
231
232 ret[in_len] = L'\0';
233
234 assert(ret && !save_in_len ? wcslen(ret) == in_len : 1);
235
236 if (PHP_WIN32_CP_IGNORE_LEN_P != out_len) {
237 *out_len = in_len;
238 }
239
240 return ret;
241}/*}}}*/
242#undef ASCII_FAIL_RETURN
243
244__forceinline static char *php_win32_cp_from_w_int(const wchar_t* in, size_t in_len, size_t *out_len, UINT cp, DWORD flags)
245{/*{{{*/
246 int r;
247 int target_len, tmp_len;
248 char* target;
249
250 if (!in || in_len > INT_MAX) {
251 SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
252 return NULL;
253 }
254 assert(in_len ? in[in_len] == '\0' : 1);
255
256 tmp_len = !in_len ? -1 : (int)in_len + 1;
257
258 target_len = WideCharToMultiByte(cp, flags, in, tmp_len, NULL, 0, NULL, NULL);
259 if (target_len == 0) {
260 SET_ERRNO_FROM_WIN32_CODE(GetLastError());
261 return NULL;
262 }
263
264 target = malloc(target_len);
265 if (target == NULL) {
266 SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
267 return NULL;
268 }
269
270 r = WideCharToMultiByte(cp, flags, in, tmp_len, target, target_len, NULL, NULL);
271 if (r == 0) {
272 free(target);
273 SET_ERRNO_FROM_WIN32_CODE(GetLastError());
274 return NULL;
275 }
276
277 assert(target ? r == target_len : 1);
278 assert(target && !in_len ? strlen(target) == target_len - 1 : 1);
279
280 target[target_len-1] = '\0';
281
282 if (PHP_WIN32_CP_IGNORE_LEN_P != out_len) {
283 *out_len = target_len - 1;
284 }
285
286 return target;
287}/*}}}*/
288
289PW32CP char *php_win32_cp_conv_w_to_utf8(const wchar_t* in, size_t in_len, size_t *out_len)
290{/*{{{*/
291 return php_win32_cp_from_w_int(in, in_len, out_len, CP_UTF8, WC_ERR_INVALID_CHARS);
292}/*}}}*/
293
294PW32CP char *php_win32_cp_conv_w_to_cur(const wchar_t* in, size_t in_len, size_t *out_len)
295{/*{{{*/
296 char *ret;
297
298 ret = php_win32_cp_from_w_int(in, in_len, out_len, cur_cp->id, cur_cp->from_w_fl);
299
300 return ret;
301}/*}}}*/
302
303PW32CP char *php_win32_cp_conv_from_w(DWORD cp, DWORD flags, const wchar_t* in, size_t in_len, size_t *out_len)
304{/*{{{*/
305 return php_win32_cp_from_w_int(in, in_len, out_len, cp, flags);
306}/*}}}*/
307
308/* This is only usable after the startup phase*/
309__forceinline static char *php_win32_cp_get_enc(void)
310{/*{{{*/
311 char *enc = NULL;
312 const zend_encoding *zenc;
313
316 } else if (SG(default_charset) && SG(default_charset)[0] ) {
317 enc = SG(default_charset);
318 } else {
320 if (zenc) {
322 }
323 }
324
325 return enc;
326}/*}}}*/
327
329{/*{{{*/
330 return cur_cp;
331}/*}}}*/
332
334{/*{{{*/
335 return orig_cp;
336}/*}}}*/
337
339{/*{{{*/
340 size_t i;
341
342 if (id < php_win32_cp_map[0].id) {
343 switch (id) {
344 case CP_ACP:
345 id = GetACP();
346 break;
347 case CP_OEMCP:
348 id = GetOEMCP();
349 break;
350 }
351 }
352
353 for (i = 0; i < sizeof(php_win32_cp_map)/sizeof(struct php_win32_cp); i++) {
354 if (php_win32_cp_map[i].id == id) {
355 return &php_win32_cp_map[i];
356 }
357 }
358
359 SET_ERRNO_FROM_WIN32_CODE(ERROR_NOT_FOUND);
360
361 return NULL;
362}/*}}}*/
363
365{/*{{{*/
366 size_t enc_len = 0, i;
367
368 if (!enc || !enc[0]) {
369 return php_win32_cp_get_by_id(65001U);
370 }
371
372 enc_len = strlen(enc);
373
374 for (i = 0; i < sizeof(php_win32_cp_map)/sizeof(struct php_win32_cp); i++) {
375 const struct php_win32_cp *cp = &php_win32_cp_map[i];
376
377 if (!cp->name || !cp->name[0]) {
378 continue;
379 }
380
381 if (0 == zend_binary_strcasecmp(enc, enc_len, cp->name, strlen(cp->name))) {
382 return cp;
383 }
384
385 if (cp->enc) {
386 char *start = cp->enc, *idx;
387
388 idx = strpbrk(start, "|");
389
390 while (NULL != idx) {
391 if (0 == zend_binary_strcasecmp(enc, enc_len, start, idx - start)) {
392 return cp;
393 }
394 start = idx + 1;
395 idx = strpbrk(start, "|");
396 }
397 /* Last in the list, or single charset specified. */
398 if (0 == zend_binary_strcasecmp(enc, enc_len, start, strlen(start))) {
399 return cp;
400 }
401 }
402 }
403
404 return php_win32_cp_get_by_id(GetACP());
405}/*}}}*/
406
408{/*{{{*/
409 const struct php_win32_cp *tmp;
410 if (!IsValidCodePage(id)) {
411 SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
412 return NULL;
413 }
414
415 tmp = php_win32_cp_get_by_id(id);
416 if (tmp) {
417 cur_cp = tmp;
418 }
419
420 return cur_cp;
421}/*}}}*/
422
424{/*{{{*/
425 return 65001 == cur_cp->id;
426}/*}}}*/
427
428PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)
429{/*{{{*/
430 wchar_t *envw = NULL, ew[32760];
431 char *cur = (char *)env, *prev;
432 size_t bin_len = 0;
433
434 if (!env) {
435 SET_ERRNO_FROM_WIN32_CODE(ERROR_INVALID_PARAMETER);
436 return NULL;
437 }
438
439 do {
440 wchar_t *tmp;
441
442 tmp = php_win32_cp_any_to_w(cur);
443 if (tmp) {
444 size_t tmp_len = wcslen(tmp) + 1;
445 memmove(ew + bin_len, tmp, tmp_len * sizeof(wchar_t));
446 free(tmp);
447
448 bin_len += tmp_len;
449 }
450
451 prev = cur;
452
453 } while (NULL != (cur = strchr(prev, '\0')) && cur++ && *cur && bin_len + (cur - prev) < 32760);
454
455 envw = (wchar_t *) malloc((bin_len + 3) * sizeof(wchar_t));
456 if (!envw) {
457 SET_ERRNO_FROM_WIN32_CODE(ERROR_OUTOFMEMORY);
458 return NULL;
459 }
460 memmove(envw, ew, bin_len * sizeof(wchar_t));
461 envw[bin_len] = L'\0';
462 envw[bin_len + 1] = L'\0';
463 envw[bin_len + 2] = L'\0';
464
465 return envw;
466}/*}}}*/
467
468static BOOL php_win32_cp_cli_io_setup(void)
469{/*{{{*/
470 BOOL ret = TRUE;
471
472 if (PG(input_encoding) && PG(input_encoding)[0]) {
473 cur_in_cp = php_win32_cp_get_by_enc(PG(input_encoding));
474 if (!cur_in_cp) {
476 }
477 } else {
479 }
480
481 if (PG(output_encoding) && PG(output_encoding)[0]) {
482 cur_out_cp = php_win32_cp_get_by_enc(PG(output_encoding));
483 if (!cur_out_cp) {
485 }
486 } else {
488 }
489
491 ret = SetConsoleCP(cur_in_cp->id) && SetConsoleOutputCP(cur_out_cp->id);
492 }
493
494 return ret;
495}/*}}}*/
496
498{/*{{{*/
499 if (!enc) {
500 enc = php_win32_cp_get_enc();
501 }
502
504 if (!orig_cp) {
506 }
508 if (!orig_in_cp) {
509 orig_in_cp = php_win32_cp_get_by_id(GetConsoleCP());
510 if (!orig_in_cp) {
512 }
513 }
514 if (!orig_out_cp) {
515 orig_out_cp = php_win32_cp_get_by_id(GetConsoleOutputCP());
516 if (!orig_out_cp) {
518 }
519 }
520 php_win32_cp_cli_io_setup();
521 }
522
523 return cur_cp;
524}/*}}}*/
525
527{/*{{{*/
528 if (!enc) {
529 enc = php_win32_cp_get_enc();
530 }
532
535 }
536
537 return cur_cp;
538}/*}}}*/
539
541{/*{{{*/
542 return orig_cp;
543}/*}}}*/
544
545/* php_win32_cp_setup() needs to have run before! */
547{/*{{{*/
548 const struct php_win32_cp *cp;
549
550 if (!orig_cp) {
552 }
553
554 if (id) {
556 } else {
557 cp = cur_cp;
558 }
559
560 if (!cp) {
561 return NULL;
562 }
563
564 if (php_win32_cp_cli_io_setup()) {
565 return cp;
566 }
567
568 return cp;
569}/*}}}*/
570
572{/*{{{*/
573 BOOL cli_io_restored = TRUE;
574
575 if (orig_in_cp) {
576 cli_io_restored = cli_io_restored && SetConsoleCP(orig_in_cp->id);
577 }
578
579 if (orig_out_cp) {
580 cli_io_restored = cli_io_restored && SetConsoleOutputCP(orig_out_cp->id);
581 }
582
583 if (cli_io_restored && id) {
584 return php_win32_cp_set_by_id(id);
585 }
586
587 return NULL;
588}/*}}}*/
589
590/* Userspace functions, see basic_functions.* for arginfo and decls. */
591
592/* {{{ Set process codepage. */
594{
596 const struct php_win32_cp *cp;
597
598 if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id) == FAILURE) {
600 }
601
602 if (ZEND_LONG_UINT_OVFL(id)) {
603 zend_argument_value_error(1, "must be between 0 and %u", UINT_MAX);
605 }
606
609 } else {
611 }
612 if (!cp) {
613 php_error_docref(NULL, E_WARNING, "Failed to switch to codepage %d", id);
615 }
616
617 RETURN_BOOL(cp->id == id);
618}
619/* }}} */
620
621/* {{{ Get process codepage. */
623{
625
628 }
629
630 if (!kind) {
631 const struct php_win32_cp *cp = php_win32_cp_get_current();
632 RETURN_LONG(cp->id);
633 } else if (zend_string_equals_literal_ci(kind, "ansi")) {
634 RETURN_LONG(GetACP());
635 } else if (zend_string_equals_literal_ci(kind, "oem")) {
636 RETURN_LONG(GetOEMCP());
637 } else {
638 /* TODO Warn/ValueError for invalid kind? */
639 const struct php_win32_cp *cp = php_win32_cp_get_current();
640 RETURN_LONG(cp->id);
641 }
642}
643/* }}} */
644
645
646/* {{{ Indicates whether the codepage is UTF-8 compatible. */
655/* }}} */
656
657/* {{{ Convert string from one codepage to another. */
659{
660 char *ret;
661 size_t ret_len, tmpw_len;
662 wchar_t *tmpw;
663 const struct php_win32_cp *in_cp, *out_cp;
664 zend_string *string_in_codepage = NULL;
665 zend_long int_in_codepage = 0;
666 zend_string *string_out_codepage = NULL;
667 zend_long int_out_codepage = 0;
668 zend_string *subject;
669
671 Z_PARAM_STR_OR_LONG(string_in_codepage, int_in_codepage)
672 Z_PARAM_STR_OR_LONG(string_out_codepage, int_out_codepage)
673 Z_PARAM_STR(subject)
675
676 if (ZEND_SIZE_T_INT_OVFL(ZSTR_LEN(subject))) {
677 zend_argument_value_error(1, "is too long");
679 }
680
681 if (string_in_codepage != NULL) {
682 in_cp = php_win32_cp_get_by_enc(ZSTR_VAL(string_in_codepage));
683 if (!in_cp) {
684 zend_argument_value_error(1, "must be a valid charset");
686 }
687 } else {
688 if (ZEND_LONG_UINT_OVFL(int_in_codepage)) {
689 zend_argument_value_error(1, "must be between 0 and %u", UINT_MAX);
691 }
692
693 in_cp = php_win32_cp_get_by_id((DWORD)int_in_codepage);
694 if (!in_cp) {
695 zend_argument_value_error(1, "must be a valid codepage");
697 }
698 }
699
700 if (string_out_codepage != NULL) {
701 out_cp = php_win32_cp_get_by_enc(ZSTR_VAL(string_out_codepage));
702 if (!out_cp) {
703 zend_argument_value_error(2, "must be a valid charset");
705 }
706 } else {
707 if (ZEND_LONG_UINT_OVFL(int_out_codepage)) {
708 zend_argument_value_error(2, "must be between 0 and %u", UINT_MAX);
710 }
711
712 out_cp = php_win32_cp_get_by_id((DWORD)int_out_codepage);
713 if (!out_cp) {
714 zend_argument_value_error(2, "must be a valid codepage");
716 }
717 }
718
719 tmpw = php_win32_cp_conv_to_w(in_cp->id, in_cp->to_w_fl, ZSTR_VAL(subject), ZSTR_LEN(subject), &tmpw_len);
720 if (!tmpw) {
721 php_error_docref(NULL, E_WARNING, "Wide char conversion failed");
722 RETURN_NULL();
723 }
724
725 ret = php_win32_cp_conv_from_w(out_cp->id, out_cp->from_w_fl, tmpw, tmpw_len, &ret_len);
726 if (!ret) {
727 free(tmpw);
728 php_error_docref(NULL, E_WARNING, "Wide char conversion failed");
729 RETURN_NULL();
730 }
731
732 RETVAL_STRINGL(ret, ret_len);
733
734 free(tmpw);
735 free(ret);
736}
737/* }}} */
738
739/* }}} */
#define SG(v)
Definition SAPI.h:160
sapi_windows_cp_get(string $kind="")
sapi_windows_cp_conv(int|string $in_codepage, int|string $out_codepage, string $subject)
prev(array|object &$array)
sapi_windows_cp_is_utf8()
sapi_windows_cp_set(int $codepage)
strpbrk(string $string, string $characters)
assert(mixed $assertion, Throwable|string|null $description=null)
strchr(string $haystack, string $needle, bool $before_needle=false)
PW32CP const struct php_win32_cp * php_win32_cp_cli_do_restore(DWORD id)
Definition codepage.c:571
PW32CP BOOL php_win32_cp_use_unicode(void)
Definition codepage.c:423
PW32CP const struct php_win32_cp * php_win32_cp_shutdown(void)
Definition codepage.c:540
PW32CP const struct php_win32_cp * php_win32_cp_do_update(const char *enc)
Definition codepage.c:526
PW32CP wchar_t * php_win32_cp_conv_ascii_to_w(const char *in, size_t in_len, size_t *out_len)
Definition codepage.c:106
ZEND_TLS const struct php_win32_cp * cur_out_cp
Definition codepage.c:31
PW32CP wchar_t * php_win32_cp_conv_cur_to_w(const char *in, size_t in_len, size_t *out_len)
Definition codepage.c:87
PW32CP const struct php_win32_cp * php_win32_cp_get_current(void)
Definition codepage.c:328
#define ASCII_FAIL_RETURN()
Definition codepage.c:101
PW32CP const struct php_win32_cp * php_win32_cp_set_by_id(DWORD id)
Definition codepage.c:407
ZEND_TLS const struct php_win32_cp * orig_in_cp
Definition codepage.c:34
PW32CP char * php_win32_cp_conv_w_to_cur(const wchar_t *in, size_t in_len, size_t *out_len)
Definition codepage.c:294
PW32CP const struct php_win32_cp * php_win32_cp_do_setup(const char *enc)
Definition codepage.c:497
PW32CP wchar_t * php_win32_cp_conv_to_w(DWORD cp, DWORD flags, const char *in, size_t in_len, size_t *out_len)
Definition codepage.c:96
PW32CP const struct php_win32_cp * php_win32_cp_get_orig(void)
Definition codepage.c:333
PW32CP wchar_t * php_win32_cp_conv_utf8_to_w(const char *in, size_t in_len, size_t *out_len)
Definition codepage.c:82
ZEND_TLS const struct php_win32_cp * cur_in_cp
Definition codepage.c:33
PW32CP const struct php_win32_cp * php_win32_cp_get_by_enc(const char *enc)
Definition codepage.c:364
ZEND_TLS const struct php_win32_cp * cur_cp
Definition codepage.c:29
ZEND_TLS const struct php_win32_cp * orig_cp
Definition codepage.c:30
PW32CP const struct php_win32_cp * php_win32_cp_cli_do_setup(DWORD id)
Definition codepage.c:546
ZEND_TLS const struct php_win32_cp * orig_out_cp
Definition codepage.c:32
PW32CP const struct php_win32_cp * php_win32_cp_get_by_id(DWORD id)
Definition codepage.c:338
PW32CP wchar_t * php_win32_cp_env_any_to_w(const char *env)
Definition codepage.c:428
PW32CP char * php_win32_cp_conv_w_to_utf8(const wchar_t *in, size_t in_len, size_t *out_len)
Definition codepage.c:289
PW32CP char * php_win32_cp_conv_from_w(DWORD cp, DWORD flags, const wchar_t *in, size_t in_len, size_t *out_len)
Definition codepage.c:303
#define php_win32_cp_setup()
Definition codepage.h:45
#define php_win32_cp_any_to_w(in)
Definition codepage.h:115
#define PHP_WIN32_CP_IGNORE_LEN_P
Definition codepage.h:31
#define PW32CP
Definition codepage.h:27
const CP_ACP
const CP_UTF8
const CP_OEMCP
PHP_WINUTIL_API BOOL php_win32_console_is_cli_sapi(void)
Definition console.c:112
#define DWORD
Definition exif.c:1762
new_type kind
Definition ffi.c:4363
buf start
Definition ffi.c:4687
#define TRUE
Definition gd_gd.c:7
#define NULL
Definition gdcache.h:45
PHPAPI bool php_get_module_initialized(void)
Definition main.c:851
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
const mbfl_encoding * internal_encoding
Definition mbstring.h:74
int BOOL
#define memmove(a, b, c)
#define PHP_FUNCTION
Definition php.h:364
#define INT_MAX
Definition php.h:237
unsigned const char * end
Definition php_ffi.h:51
#define PG(v)
Definition php_globals.h:31
char * name
char * enc
DWORD id
DWORD from_w_fl
Definition codepage.h:36
DWORD to_w_fl
Definition codepage.h:35
char * enc
Definition codepage.h:39
#define SET_ERRNO_FROM_WIN32_CODE(err)
Definition winutil.h:47
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define ZEND_PARSE_PARAMETERS_END()
Definition zend_API.h:1641
#define RETURN_FALSE
Definition zend_API.h:1058
#define RETURN_NULL()
Definition zend_API.h:1036
#define zend_parse_parameters_none()
Definition zend_API.h:353
#define Z_PARAM_STR(dest)
Definition zend_API.h:2086
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
Definition zend_API.h:1620
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_BOOL(b)
Definition zend_API.h:1035
#define RETURN_THROWS()
Definition zend_API.h:1060
#define Z_PARAM_STR_OR_LONG(dest_str, dest_long)
Definition zend_API.h:2165
#define RETVAL_STRINGL(s, l)
Definition zend_API.h:1018
strlen(string $string)
#define E_WARNING
Definition zend_errors.h:24
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
ZEND_API const char * zend_multibyte_get_encoding_name(const zend_encoding *encoding)
ZEND_API const zend_encoding * zend_multibyte_get_internal_encoding(void)
struct _zend_encoding zend_encoding
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2)
#define ZEND_SLIDE_TO_ALIGNED16(ptr)
#define ZEND_LONG_UINT_OVFL(zlong)
#define ZEND_SIZE_T_INT_OVFL(size)
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define zend_string_equals_literal_ci(str, c)
@ FAILURE
Definition zend_types.h:61
#define ZEND_TLS
Definition zend_types.h:84
zval * ret