library doesn't support iconv stream filter #72

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

Comments

Projects
None yet
6 participants
@nsitbon

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

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 20, 2015

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

Member

nyamsprod commented Feb 20, 2015

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

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 20, 2015

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.

Member

nyamsprod commented Feb 20, 2015

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

This comment has been minimized.

Show comment
Hide comment
@nsitbon

nsitbon 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.

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

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 20, 2015

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.

Member

nyamsprod commented Feb 20, 2015

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

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 23, 2015

Member

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

Member

nyamsprod commented Feb 23, 2015

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

@nsitbon

This comment has been minimized.

Show comment
Hide comment
@nsitbon

nsitbon Feb 23, 2015

thank you much Ignace.

nsitbon commented Feb 23, 2015

thank you much Ignace.

@nsitbon nsitbon closed this Feb 23, 2015

@zerocrates

This comment has been minimized.

Show comment
Hide comment
@zerocrates

zerocrates Feb 8, 2016

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.

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 League\Csv
- bug fix stream filter #72
- improve public API by deprecating (get|set)EncodingFrom
@nyamsprod

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 9, 2016

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 👍

Member

nyamsprod commented Feb 9, 2016

@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

@nyamsprod nyamsprod referenced this issue Feb 9, 2016

Merged

Bugfix Library #152

@nsitbon

This comment has been minimized.

Show comment
Hide comment
@nsitbon

nsitbon Feb 9, 2016

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

nsitbon commented Feb 9, 2016

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

@nyamsprod

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod Feb 12, 2016

Member

bug fix is merged in master branch

Member

nyamsprod commented Feb 12, 2016

bug fix is merged in master branch

@nyamsprod nyamsprod closed this Feb 12, 2016

@mrfinrod

This comment has been minimized.

Show comment
Hide comment
@mrfinrod

mrfinrod 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?

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

This comment has been minimized.

Show comment
Hide comment
@landsman

landsman Feb 28, 2018

Same problem here ...

Same problem here ...

@spagu

This comment has been minimized.

Show comment
Hide comment
@spagu

spagu May 12, 2018

and here.

spagu commented May 12, 2018

and here.

@nyamsprod

This comment has been minimized.

Show comment
Hide comment
@nyamsprod

nyamsprod May 14, 2018

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

Member

nyamsprod commented May 14, 2018

@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