Check if the string is valid for the specified encoding */
PHP_FUNCTION(mb_check_encoding)
{
- zval *input = NULL;
- zend_string *enc = NULL;
+ zend_string *input_str = NULL, *enc = NULL;
+ HashTable *input_ht = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zS", &input, &enc) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_ARRAY_HT(input_str, input_ht)
+ Z_PARAM_STR(enc)
+ ZEND_PARSE_PARAMETERS_END();
- /* FIXME: Actually check all inputs, except $_FILES file content. */
- if (input == NULL) {
- if (MBSTRG(illegalchars) == 0) {
- RETURN_TRUE;
+ if (input_ht) {
+ if (!php_mb_check_encoding_recursive(input_ht, enc)) {
+ RETURN_FALSE;
}
- RETURN_FALSE;
- }
-
- if (Z_TYPE_P(input) == IS_ARRAY) {
- if (!php_mb_check_encoding_recursive(HASH_OF(input), enc)) {
+ RETURN_TRUE;
+ } else if (input_str) {
+ if (!php_mb_check_encoding(ZSTR_VAL(input_str), ZSTR_LEN(input_str), enc ? ZSTR_VAL(enc): NULL)) {
RETURN_FALSE;
}
+ RETURN_TRUE;
} else {
- if (!try_convert_to_string(input)) {
- RETURN_THROWS();
- }
- if (!php_mb_check_encoding(Z_STRVAL_P(input), Z_STRLEN_P(input), enc ? ZSTR_VAL(enc): NULL)) {
- RETURN_FALSE;
+ /* FIXME: Actually check all inputs, except $_FILES file content. */
+ if (MBSTRG(illegalchars) == 0) {
+ RETURN_TRUE;
}
+ RETURN_FALSE;
}
- RETURN_TRUE;
}
/* }}} */
function mb_detect_order($encoding = UNKNOWN): array|bool {}
+/** @param string|int $substchar */
function mb_substitute_character($substchar = UNKNOWN): string|int|bool {}
function mb_preferred_mime_name(string $encoding): string|false {}
function mb_get_info(string $type = UNKNOWN): array|string|int|false {}
-function mb_check_encoding($var = UNBEK, string $encoding = UNKNOWN): bool {}
+function mb_check_encoding(array|string $var = UNKNOWN, string $encoding = UNKNOWN): bool {}
function mb_scrub(string $str, string $encoding = UNKNOWN): string|false {}
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mb_check_encoding, 0, 0, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, var)
+ ZEND_ARG_TYPE_MASK(0, var, MAY_BE_ARRAY|MAY_BE_STRING)
ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0)
ZEND_END_ARG_INFO()