xref: /PHP-7.4/win32/codepage.h (revision 92ac598a)
13d3f11edSAnatol Belski /*
23d3f11edSAnatol Belski    +----------------------------------------------------------------------+
33d3f11edSAnatol Belski    | PHP Version 7                                                        |
43d3f11edSAnatol Belski    +----------------------------------------------------------------------+
5*0cf7de1cSZeev Suraski    | Copyright (c) The PHP Group                                          |
63d3f11edSAnatol Belski    +----------------------------------------------------------------------+
73d3f11edSAnatol Belski    | This source file is subject to version 3.01 of the PHP license,      |
83d3f11edSAnatol Belski    | that is bundled with this package in the file LICENSE, and is        |
93d3f11edSAnatol Belski    | available through the world-wide-web at the following url:           |
103d3f11edSAnatol Belski    | http://www.php.net/license/3_01.txt                                  |
113d3f11edSAnatol Belski    | If you did not receive a copy of the PHP license and are unable to   |
123d3f11edSAnatol Belski    | obtain it through the world-wide-web, please send a note to          |
133d3f11edSAnatol Belski    | license@php.net so we can mail you a copy immediately.               |
143d3f11edSAnatol Belski    +----------------------------------------------------------------------+
153d3f11edSAnatol Belski    | Author: Anatol Belski <ab@php.net>                                   |
163d3f11edSAnatol Belski    +----------------------------------------------------------------------+
173d3f11edSAnatol Belski */
183d3f11edSAnatol Belski 
193d3f11edSAnatol Belski #ifndef PHP_WIN32_CODEPAGE_H
203d3f11edSAnatol Belski #define PHP_WIN32_CODEPAGE_H
213d3f11edSAnatol Belski 
223d3f11edSAnatol Belski #ifdef __cplusplus
233d3f11edSAnatol Belski extern "C" {
243d3f11edSAnatol Belski #endif
253d3f11edSAnatol Belski 
263d3f11edSAnatol Belski #ifdef PHP_EXPORTS
273d3f11edSAnatol Belski # define PW32CP __declspec(dllexport)
283d3f11edSAnatol Belski #else
293d3f11edSAnatol Belski # define PW32CP __declspec(dllimport)
303d3f11edSAnatol Belski #endif
313d3f11edSAnatol Belski 
323d3f11edSAnatol Belski #define PHP_WIN32_CP_IGNORE_LEN (0)
333d3f11edSAnatol Belski #define PHP_WIN32_CP_IGNORE_LEN_P ((size_t *)-1)
343d3f11edSAnatol Belski 
353d3f11edSAnatol Belski struct php_win32_cp {
363d3f11edSAnatol Belski 	DWORD id;
373d3f11edSAnatol Belski 	DWORD to_w_fl;
383d3f11edSAnatol Belski 	DWORD from_w_fl;
393d3f11edSAnatol Belski 	DWORD char_size;
403d3f11edSAnatol Belski 	char *name;
413d3f11edSAnatol Belski 	char *enc;
423d3f11edSAnatol Belski 	char *desc;
433d3f11edSAnatol Belski };
443d3f11edSAnatol Belski 
453d3f11edSAnatol Belski PW32CP BOOL php_win32_cp_use_unicode(void);
463d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_do_setup(const char *);
473d3f11edSAnatol Belski #define php_win32_cp_setup() php_win32_cp_do_setup(NULL)
483d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_do_update(const char *);
493d3f11edSAnatol Belski #define php_win32_cp_update() php_win32_cp_do_update(NULL)
503d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_shutdown(void);
513d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_get_current(void);
523d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_get_orig(void);
533d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_get_by_id(DWORD id);
543d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_set_by_id(DWORD id);
553d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_get_by_enc(const char *enc);
563d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_cli_do_setup(DWORD);
573d3f11edSAnatol Belski #define php_win32_cp_cli_setup() php_win32_cp_cli_do_setup(0)
583d3f11edSAnatol Belski #define php_win32_cp_cli_update() php_win32_cp_cli_do_setup(0)
593d3f11edSAnatol Belski PW32CP const struct php_win32_cp *php_win32_cp_cli_do_restore(DWORD);
603d3f11edSAnatol Belski #define php_win32_cp_cli_restore() php_win32_cp_cli_do_restore(0)
613d3f11edSAnatol Belski 
623d3f11edSAnatol Belski /* This API is binary safe and expects a \0 terminated input.
633d3f11edSAnatol Belski    The returned out is \0 terminated, but the length doesn't count \0. */
643d3f11edSAnatol Belski PW32CP wchar_t *php_win32_cp_conv_to_w(DWORD in_cp, DWORD flags, const char* in, size_t in_len, size_t *out_len);
653d3f11edSAnatol Belski PW32CP wchar_t *php_win32_cp_conv_utf8_to_w(const char* in, size_t in_len, size_t *out_len);
663d3f11edSAnatol Belski #define php_win32_cp_utf8_to_w(in) php_win32_cp_conv_utf8_to_w(in, PHP_WIN32_CP_IGNORE_LEN, PHP_WIN32_CP_IGNORE_LEN_P)
673d3f11edSAnatol Belski PW32CP wchar_t *php_win32_cp_conv_cur_to_w(const char* in, size_t in_len, size_t *out_len);
683d3f11edSAnatol Belski #define php_win32_cp_cur_to_w(in) php_win32_cp_conv_cur_to_w(in, PHP_WIN32_CP_IGNORE_LEN, PHP_WIN32_CP_IGNORE_LEN_P)
693d3f11edSAnatol Belski PW32CP wchar_t *php_win32_cp_conv_ascii_to_w(const char* in, size_t in_len, size_t *out_len);
703d3f11edSAnatol Belski #define php_win32_cp_ascii_to_w(in) php_win32_cp_conv_ascii_to_w(in, PHP_WIN32_CP_IGNORE_LEN, PHP_WIN32_CP_IGNORE_LEN_P)
713d3f11edSAnatol Belski PW32CP char *php_win32_cp_conv_from_w(DWORD out_cp, DWORD flags, const wchar_t* in, size_t in_len, size_t *out_len);
723d3f11edSAnatol Belski PW32CP char *php_win32_cp_conv_w_to_utf8(const wchar_t* in, size_t in_len, size_t *out_len);
733d3f11edSAnatol Belski #define php_win32_cp_w_to_utf8(in) php_win32_cp_conv_w_to_utf8(in, PHP_WIN32_CP_IGNORE_LEN, PHP_WIN32_CP_IGNORE_LEN_P)
743d3f11edSAnatol Belski PW32CP char *php_win32_cp_conv_w_to_cur(const wchar_t* in, size_t in_len, size_t *out_len);
753d3f11edSAnatol Belski #define php_win32_cp_w_to_cur(in) php_win32_cp_conv_w_to_cur(in, PHP_WIN32_CP_IGNORE_LEN, PHP_WIN32_CP_IGNORE_LEN_P)
76