Returns converted string in desired encoding */
PHP_FUNCTION(mb_convert_encoding)
{
- zval *input;
zend_string *to_encoding_name;
- zend_string *from_encodings_str = NULL;
- HashTable *from_encodings_ht = NULL;
+ zend_string *input_str, *from_encodings_str = NULL;
+ HashTable *input_ht, *from_encodings_ht = NULL;
const mbfl_encoding *to_encoding;
const mbfl_encoding **from_encodings;
size_t num_from_encodings;
zend_bool free_from_encodings;
ZEND_PARSE_PARAMETERS_START(2, 3)
- Z_PARAM_ZVAL(input)
+ Z_PARAM_STR_OR_ARRAY_HT(input_str, input_ht)
Z_PARAM_STR(to_encoding_name)
Z_PARAM_OPTIONAL
Z_PARAM_STR_OR_ARRAY_HT(from_encodings_str, from_encodings_ht)
RETURN_FALSE;
}
- if (Z_TYPE_P(input) != IS_STRING && Z_TYPE_P(input) != IS_ARRAY) {
- if (!try_convert_to_string(input)) {
- RETURN_THROWS();
- }
- }
-
if (from_encodings_ht) {
if (php_mb_parse_encoding_array(from_encodings_ht, &from_encodings, &num_from_encodings, 0) == FAILURE) {
RETURN_FALSE;
RETURN_FALSE;
}
- if (Z_TYPE_P(input) == IS_STRING) {
+ if (input_str) {
/* new encoding */
size_t size;
char *ret = php_mb_convert_encoding(
- Z_STRVAL_P(input), Z_STRLEN_P(input),
+ ZSTR_VAL(input_str), ZSTR_LEN(input_str),
to_encoding, from_encodings, num_from_encodings, &size);
if (ret != NULL) {
// TODO: avoid reallocation ???
} else {
HashTable *tmp;
tmp = php_mb_convert_encoding_recursive(
- Z_ARRVAL_P(input), to_encoding, from_encodings, num_from_encodings);
+ input_ht, to_encoding, from_encodings, num_from_encodings);
RETVAL_ARR(tmp);
}
function mb_strimwidth(string $str, int $start, int $width, string $trimmarker = UNKNOWN, string $encoding = UNKNOWN): string|false {}
-/** @param array|string $str */
-function mb_convert_encoding($str, string $to, array|string $from = UNKNOWN): array|string|false {}
+function mb_convert_encoding(array|string $str, string $to, array|string $from = UNKNOWN): array|string|false {}
function mb_convert_case(string $sourcestring, int $mode, ?string $encoding = null): string|false {}
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_convert_encoding, 0, 2, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, str)
+ ZEND_ARG_TYPE_MASK(0, str, MAY_BE_ARRAY|MAY_BE_STRING)
ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, from, MAY_BE_ARRAY|MAY_BE_STRING)
ZEND_END_ARG_INFO()