Php call to undefined function iconv in

Не работает функция iconv(), а нужно конвертнуть из UTF-8 в windows-1251

Реально очень полезная выручалка, в том случае если никак не получается совладать с кодировкой и локалями на серваке.

а куда ее вставить? я в пхп не силен, у меня на каталоге VirtueMart такая хрень. причем первый раз. раньше как то не было. хз в чем проблема

Не всегда функция strlen() на хостингах включена, встречалась и такая проблема, поэтому еще один вариант, более актуальный:

function utf8_to_win1251($text)
$text=str_replace(«\xD0\xB0″,»а»,$text); $text=str_replace(«\xD0\x90″,»А»,$text);
$text=str_replace(«\xD0\xB1″,»б»,$text); $text=str_replace(«\xD0\x91″,»Б»,$text);
$text=str_replace(«\xD0\xB2″,»в»,$text); $text=str_replace(«\xD0\x92″,»В»,$text);
$text=str_replace(«\xD0\xB3″,»г»,$text); $text=str_replace(«\xD0\x93″,»Г»,$text);
$text=str_replace(«\xD0\xB4″,»д»,$text); $text=str_replace(«\xD0\x94″,»Д»,$text);
$text=str_replace(«\xD0\xB5″,»е»,$text); $text=str_replace(«\xD0\x95″,»Е»,$text);
$text=str_replace(«\xD1\x91″,»ё»,$text); $text=str_replace(«\xD0\x81″,»Ё»,$text);
$text=str_replace(«\xD0\xB6″,»ж»,$text); $text=str_replace(«\xD0\x96″,»Ж»,$text);
$text=str_replace(«\xD0\xB7″,»з»,$text); $text=str_replace(«\xD0\x97″,»З»,$text);
$text=str_replace(«\xD0\xB8″,»и»,$text); $text=str_replace(«\xD0\x98″,»И»,$text);
$text=str_replace(«\xD0\xB9″,»й»,$text); $text=str_replace(«\xD0\x99″,»Й»,$text);
$text=str_replace(«\xD0\xBA»,»к»,$text); $text=str_replace(«\xD0\x9A»,»К»,$text);
$text=str_replace(«\xD0\xBB»,»л»,$text); $text=str_replace(«\xD0\x9B»,»Л»,$text);
$text=str_replace(«\xD0\xBC»,»м»,$text); $text=str_replace(«\xD0\x9C»,»М»,$text);
$text=str_replace(«\xD0\xBD»,»н»,$text); $text=str_replace(«\xD0\x9D»,»Н»,$text);
$text=str_replace(«\xD0\xBE»,»о»,$text); $text=str_replace(«\xD0\x9E»,»О»,$text);
$text=str_replace(«\xD0\xBF»,»п»,$text); $text=str_replace(«\xD0\x9F»,»П»,$text);
$text=str_replace(«\xD1\x80″,»р»,$text); $text=str_replace(«\xD0\xA0″,»Р»,$text);
$text=str_replace(«\xD1\x81″,»с»,$text); $text=str_replace(«\xD0\xA1″,»С»,$text);
$text=str_replace(«\xD1\x82″,»т»,$text); $text=str_replace(«\xD0\xA2″,»Т»,$text);
$text=str_replace(«\xD1\x83″,»у»,$text); $text=str_replace(«\xD0\xA3″,»У»,$text);
$text=str_replace(«\xD1\x84″,»ф»,$text); $text=str_replace(«\xD0\xA4″,»Ф»,$text);
$text=str_replace(«\xD1\x85″,»х»,$text); $text=str_replace(«\xD0\xA5″,»Х»,$text);
$text=str_replace(«\xD1\x86″,»ц»,$text); $text=str_replace(«\xD0\xA6″,»Ц»,$text);
$text=str_replace(«\xD1\x87″,»ч»,$text); $text=str_replace(«\xD0\xA7″,»Ч»,$text);
$text=str_replace(«\xD1\x88″,»ш»,$text); $text=str_replace(«\xD0\xA8″,»Ш»,$text);
$text=str_replace(«\xD1\x89″,»щ»,$text); $text=str_replace(«\xD0\xA9″,»Щ»,$text);
$text=str_replace(«\xD1\x8A»,»ъ»,$text); $text=str_replace(«\xD0\xAA»,»Ъ»,$text);
$text=str_replace(«\xD1\x8B»,»ы»,$text); $text=str_replace(«\xD0\xAB»,»Ы»,$text);
$text=str_replace(«\xD1\x8C»,»ь»,$text); $text=str_replace(«\xD0\xAC»,»Ь»,$text);
$text=str_replace(«\xD1\x8D»,»э»,$text); $text=str_replace(«\xD0\xAD»,»Э»,$text);
$text=str_replace(«\xD1\x8E»,»ю»,$text); $text=str_replace(«\xD0\xAE»,»Ю»,$text);
$text=str_replace(«\xD1\x8F»,»я»,$text); $text=str_replace(«\xD0\xAF»,»Я»,$text);
$text=str_replace(«\xe2\x84\x96″,»№»,$text);
return $text;
>

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Читайте также:  How to make plots in python

Already on GitHub? Sign in to your account

Fatal error: Call to undefined function . iconv() #4700

Fatal error: Call to undefined function . iconv() #4700

Comments

Summary
When attempting to search and replace in the database, issue the following command and receive the following response:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'ReactiveChild\ReactiveChildFunctions' does not have a method 'meta_boxes' in /home/monroeathazeltin/public_html/wp-includes/class-wp-hook.php on line 286 Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///home/monroeathazeltin/wp-cli.phar/vendor/symfony/polyfill-mbstring/Mbstring.php on line 534 
$ php --ri iconv iconv iconv support => enabled iconv implementation => glibc iconv library version => 2.12 Directive => Local Value => Master Value iconv.input_encoding => no value => no value iconv.output_encoding => no value => no value iconv.internal_encoding => no value => no value 

The text was updated successfully, but these errors were encountered:

Weird though in this case if iconv() is enabled, hard to make sense of it.

Right. Iconv is enabled per the data I provided. Both links shared here presuppose that it isn’t installed?

@holisticnetworking would it be possible for you to install the PHP extension xdebug so that a stack backtrace is generated on the error in order to debug further what’s happening here?

@gitlost I’ve got xdebug installed. But can you give me a little insight as to what you want to see?

Sorry, but I’ve only ever used xdebug with PHPStorm locally, and even that, not terribly successfully.

Just wanted to see what was calling mb_strwidth() to cause the error you’re getting at Mbstring.php#L534. With xdebug installed, should get a Stack trace which will show what’s calling it. Only need to run WP-CLI with it enabled on the command line.

(May not give much more info, to be honest, but may build a PHP with iconv disabled if have further clues. )

Читайте также:  Java 6 runtime headless

@holisticnetworking if you could post the output of wp cli info it’d be useful as well ta.

Hmm, just noticed you said you’ve got xdebug already installed! Could you do php —info | grep xdebug to be sure?!

Okay reproduced the error message with a PHP with iconv() disabled (and xdebug installed):

Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/Mbstring.php:534 Stack trace: #0 phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php(46): Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth('Table', 'ASCII') #1 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/cli.php(345): mb_strwidth('Table', 'ASCII') #2 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php(200): cli\strwidth('Table', 'ASCII') #3 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/table/Ascii.php(138): cli\Colors::width('Table', false, 'ASCII') #4 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Table.php(146): cli\table\Ascii->row(Array) #5 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Table.php(125): cli\Table->getDisplayLines() #6 phar:///home/mburke/bin/wp/vendor/wp-cli/search-replace-command/src/Search_Replace_Command.php(376): cli\Table->display() #7 [i in phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/Mbstring.php on line 534 

so I think the PHP you’re using must have iconv() disabled, despite the results of php —ri iconv posted.

not including the iconv polyfill is deliberate Symfony policy, maybe adding a check to WP-CLI to warn if both iconv and the mbstring aren’t available is something to be considered, to avoid this user experience.

(May also gird myself up to raise an issue/PR about this at Symfony as it’s poor behavior really. )

I’m not sure what the problem is or was: I’ve had mbstring installed forever and certainly installed all the dependencies. However, after installing xdebug and reloading the server, now everything’s fine. Call it gremlins. But I guess I’m ok. Thanks for the help, everybody! Thomas J Belknap Senior Web Developer 585.305.1619 http://holisticnetworking.net

On Mon, Feb 26, 2018 at 6:48 PM, gitlost ***@***.***> wrote: Okay reproduced the error message with a PHP with iconv() disabled (and xdebug installed): Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/Mbstring.php:534 Stack trace: #0 phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/bootstrap.php(46): Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth(‘Table’, ‘ASCII’) #1 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/cli.php(345): mb_strwidth(‘Table’, ‘ASCII’) #2 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php(200): cli\strwidth(‘Table’, ‘ASCII’) #3 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/table/Ascii.php(138): cli\Colors::width(‘Table’, false, ‘ASCII’) #4 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Table.php(146): cli\table\Ascii->row(Array) #5 phar:///home/mburke/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Table.php(125): cli\Table->getDisplayLines() #6 phar:///home/mburke/bin/wp/vendor/wp-cli/search-replace-command/src/Search_Replace_Command.php(376): cli\Table->display() #7 [i in phar:///home/mburke/bin/wp/vendor/symfony/polyfill-mbstring/Mbstring.php on line 534 so I think the PHP you’re using must have iconv() disabled, despite the results of php —ri iconv posted. Given that according to Related: symfony/polyfill#66 not including the iconv polyfill is deliberate Symfony policy, maybe adding a check to WP-CLI to warn if both iconv and the mbstring aren’t available is something to be considered, to avoid this user experience. (May also gird myself up to raise an issue/PR about this at Symfony as it’s poor behavior really. ) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .

Читайте также:  Php telegram bot api composer

Источник

Enabling iconv php extension without recompiling PHP

I have faced a issue while loading a php script on the server. Error shown below

Fatal error: Call to undefined function iconv_get_encoding() in /home/username/public_html/rss/library/Zend/Validate/Hostname.php on line 548

This is due to missing php extension iconv. We can enable this php extension without recompiling PHP.

Follow the steps to Enable iconv php extension
==
Check the php version on the server.
#php -v

PHP 5.2.17 (cli) (built: Oct 19 2012 16:10:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

Downloading the same php version source code from http://museum.php.net/

tar -zvxf php-5.2.17.tar.gz

cd php-5.2.17/ext/iconv

Prepare php extension to compile it.
phpize

Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

aclocal
./configure
make
make install

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

Now the module installed in the location /usr/local/lib/php/extensions/no-debug-non-zts-20060613/, You can see the extension by

Now the iconv.so will be present there.

Enable iconv PHP extension in php.ini
echo “extension=iconv.so” >> /usr/local/lib/php.ini

Verify iconv :
# php -i | grep -i “iconv support”
iconv support => enabled

Источник

Оцените статью