Converts the string resource in variables to desired encoding */
PHP_FUNCTION(mb_convert_variables)
{
- zval *args, *zfrom_enc;
+ zval *args;
+ zend_string *from_enc_str;
+ HashTable *from_enc_ht;
mbfl_string string, result;
const mbfl_encoding *from_encoding, *to_encoding;
mbfl_encoding_detector *identd;
char *to_enc;
int recursion_error = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz+", &to_enc, &to_enc_len, &zfrom_enc, &args, &argc) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, -1)
+ Z_PARAM_STRING(to_enc, to_enc_len)
+ Z_PARAM_STR_OR_ARRAY_HT(from_enc_str, from_enc_ht)
+ Z_PARAM_VARIADIC('+', args, argc)
+ ZEND_PARSE_PARAMETERS_END();
/* new encoding */
to_encoding = mbfl_name2encoding(to_enc);
string.no_language = MBSTRG(language);
/* pre-conversion encoding */
- elist = NULL;
- elistsz = 0;
- switch (Z_TYPE_P(zfrom_enc)) {
- case IS_ARRAY:
- if (php_mb_parse_encoding_array(Z_ARRVAL_P(zfrom_enc), &elist, &elistsz, 0) == FAILURE) {
- RETURN_FALSE;
- }
- break;
- default:
- if (!try_convert_to_string(zfrom_enc)) {
- RETURN_THROWS();
- }
- if (php_mb_parse_encoding_list(Z_STRVAL_P(zfrom_enc), Z_STRLEN_P(zfrom_enc), &elist, &elistsz, 0) == FAILURE) {
- RETURN_FALSE;
- }
- break;
+ if (from_enc_ht) {
+ if (php_mb_parse_encoding_array(from_enc_ht, &elist, &elistsz, 0) == FAILURE) {
+ RETURN_FALSE;
+ }
+ } else {
+ if (php_mb_parse_encoding_list(ZSTR_VAL(from_enc_str), ZSTR_LEN(from_enc_str), &elist, &elistsz, 0) == FAILURE) {
+ RETURN_FALSE;
+ }
}
if (elistsz == 0) {
function mb_convert_kana(string $str, string $option = UNKNOWN, string $encoding = UNKNOWN): string|false {}
-/** @param array|string $from */
-function mb_convert_variables(string $to, $from, &$var, &...$vars): string|false {}
+function mb_convert_variables(string $to, array|string $from, &$var, &...$vars): string|false {}
function mb_encode_numericentity(string $string, array $convmap, string $encoding = UNKNOWN, bool $is_hex = false): string|false {}
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_convert_variables, 0, 3, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0)
- ZEND_ARG_INFO(0, from)
+ ZEND_ARG_TYPE_MASK(0, from, MAY_BE_ARRAY|MAY_BE_STRING)
ZEND_ARG_INFO(1, var)
ZEND_ARG_VARIADIC_INFO(1, vars)
ZEND_END_ARG_INFO()