GithubHelp home page GithubHelp logo

iconv(): Wrong charset, conversion from `GBK' to `UTF-8//IGNORE' is not allowed in /app/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php on line 2301 about aliyun-oss-php-sdk HOT 8 CLOSED

aliyun avatar aliyun commented on May 14, 2024
iconv(): Wrong charset, conversion from `GBK' to `UTF-8//IGNORE' is not allowed in /app/vendor/aliyuncs/oss-sdk-php/src/OSS/OssClient.php on line 2301

from aliyun-oss-php-sdk.

Comments (8)

solody avatar solody commented on May 14, 2024 2

The "//ignore" option doesn't work with recent versions of the iconv library. So if you're having trouble with that option, you aren't alone.

That means you can't currently use this function to filter invalid characters. Instead it silently fails and returns an empty string (or you'll get a notice but only if you have E_NOTICE enabled).

This has been a known bug with a known solution for at least since 2009 years but no one seems to be willing to fix it (PHP must pass the -c option to iconv). It's still broken as of the latest release 5.4.3.

https://bugs.php.net/bug.php?id=48147
https://bugs.php.net/bug.php?id=52211
https://bugs.php.net/bug.php?id=61484

[UPDATE 15-JUN-2012]
Here's a workaround...

ini_set('mbstring.substitute_character', "none");
$text= mb_convert_encoding($text, 'UTF-8', 'UTF-8');

That will strip invalid characters from UTF-8 strings (so that you can insert it into a database, etc.). Instead of "none" you can also use the value 32 if you want it to insert spaces in place of the invalid characters.

from aliyun-oss-php-sdk.

solody avatar solody commented on May 14, 2024 1

docker-library/php#240 如果使用了alpine系统,libiconv的版本会很低,需要更新一下 libiconv的版本

在dockerfile中添加如下命令更新

RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

from aliyun-oss-php-sdk.

inhere avatar inhere commented on May 14, 2024 1

现在应该是这样:

# testing -> community
RUN apk add --no-cache --repository http://mirrors.aliyun.com/alpine/edge/community gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

from aliyun-oss-php-sdk.

solody avatar solody commented on May 14, 2024

是Bug吗?还是我环境有问题?

from aliyun-oss-php-sdk.

solody avatar solody commented on May 14, 2024

http://php.net/manual/zh/function.iconv.php#108643

from aliyun-oss-php-sdk.

tekintian avatar tekintian commented on May 14, 2024

just remove the //IGNORE,

$options[self::OSS_OBJECT] = iconv('GBK', "UTF-8", $options[self::OSS_OBJECT]);

from aliyun-oss-php-sdk.

haoshehao avatar haoshehao commented on May 14, 2024

docker-library/php#240 如果使用了alpine系统,libiconv的版本会很低,需要更新一下 libiconv的版本

在dockerfile中添加如下命令更新

RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

docker for windows 中怎么打开dockerfile文件呢?

from aliyun-oss-php-sdk.

huiguangjun avatar huiguangjun commented on May 14, 2024

16b47c6

from aliyun-oss-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.