Skip to content
New issue

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.

Already on GitHub? Sign in to your account

library doesn't support iconv stream filter #72

Closed
nsitbon opened this issue Feb 20, 2015 · 14 comments
Closed

library doesn't support iconv stream filter #72

nsitbon opened this issue Feb 20, 2015 · 14 comments
Labels

Comments

@nsitbon
Copy link

nsitbon commented Feb 20, 2015

Hi, I just pulled the latest version of the library and try to integrate it in my application but it fails at the beginning when I do

$stream = Reader::createFromPath('/home/nsitbon/export_members_20150217.csv');

if ($stream->isActiveStreamFilter()) { 
    $stream->appendStreamFilter('convert.iconv.UTF-16/UTF-8//TRANSLIT');
}

it throws the following exception :

[RuntimeException]
SplFileObject::__construct(): unable to create or locate filter "convert.iconv.UTF-16"

whereas this code works perfectly

$stream = fopen('/home/nsitbon/export_members_20150217.csv', 'r');
$stream_filter_append($stream, 'convert.iconv.UTF-16/UTF-8//TRANSLIT', STREAM_FILTER_READ);

any ideas?

@nyamsprod
Copy link
Member

This is a limitation due to poor support from SplFileObject of stream filters. There's a open bug about this and it has not yet been resolve. When adding stream filter support I even blogged about a way to resolve it

@nyamsprod nyamsprod added the bug label Feb 20, 2015
@nyamsprod
Copy link
Member

In the meantime, nothing prevents you from modifying the FilterTranscode class to use iconv extension instead. I understand it is frustrating but if this bug was resolved a even more powerful package could be made and It would also remove the need for isActiveStreamFilter in the package.

@nsitbon
Copy link
Author

nsitbon commented Feb 20, 2015

thanks for your comments, if you can't do anything about that I'll wait for the fix in the SPL.
I spend some time in the documentation but cannot find if this behaviour is documented, can you tell me if there is something about this in the documentation. I'm sure there is nothing in the tests because I checked.

@nyamsprod
Copy link
Member

Yep there's nothing, a omission from my part. But you can make a pull request against the gh-pages branch to add the warning.

@nyamsprod
Copy link
Member

I've just updated the documentation by adding a warning section on top of the stream filter documentation page.

@nsitbon
Copy link
Author

nsitbon commented Feb 23, 2015

thank you much Ignace.

@nsitbon nsitbon closed this as completed Feb 23, 2015
@zerocrates
Copy link

FYI, the php://filter stream filter support does appear to work with filters that contain slashes, as long as you percent-encode the slashes, i.e.

php://filter/read=convert.iconv.UTF-8%2FASCII%2F%2FTRANSLIT/resource=...

The linked open PHP bug report in the docs and @nyamsprod's earlier comment indicates this doesn't work, but it appears that the filter URI support was fixed to urldecode filter specifications back in August 2008, a little bit after the still-open bug about exposing the underlying resource was filed.

It might be worth revising the warning in the documentation about this, at least as it relates to iconv filters specifically.

nyamsprod added a commit that referenced this issue Feb 9, 2016
- bug fix stream filter #72
- improve public API by deprecating (get|set)EncodingFrom
@nyamsprod
Copy link
Member

@zerocrates you are totally right seems I had overlooked this one. I've just create a PR with the fix in it. This one will be included in the next release 👍

@nyamsprod nyamsprod reopened this Feb 9, 2016
@nsitbon
Copy link
Author

nsitbon commented Feb 9, 2016

That's really cool guys thanks @zerocrates for pointing the fix and thanks @nyamsprod for implementing it ;-)

@nyamsprod
Copy link
Member

bug fix is merged in master branch

@mrfinrod
Copy link

mrfinrod commented Nov 5, 2016

I have the same problem.
Exception thrown here
if($input_bom === Reader::BOM_UTF16_LE || $input_bom === Reader::BOM_UTF16_BE) { $reader->appendStreamFilter('convert.iconv.UTF-16/UTF-8'); }
What is the solution of the problem?

@landsman
Copy link

Same problem here ...

@spagu
Copy link

spagu commented May 12, 2018

and here.

@nyamsprod
Copy link
Member

@spagu could you provide more information as this bug is related to an unsupported version of the library. It would be best to open a new thread with an example so I could investigate your issue.

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants