Re: [RFC] IntlCharsetDetector
| From: | Stanislav Malyshev | Date: | Wed, 13 Apr 2016 04:23:51 +0000 |
| Subject: | Re: [RFC] IntlCharsetDetector | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92242@lists.php.net to get a copy of this message | ||
Hi!
> That said, how do you feel about compromising by adding this function
> in addition to the raw API?
>
> function ucsdet_detect_encoding(string $text, string $hint = null,
> bool $filter = false) {
> $det = new IntlCharsetDetector($text);
> if ($hint !== null) {
> $det->setDeclaredEncoding($hint);
> }
> $det->enableInputFiltering($filter);
> return $det->detect()['name'];
> }
That works too, but object one has its uses - e.g. preparing one
detector and detecting multiple texts, like library, etc. Of course, one
can do setText, but it's extra hop that doesn't seem to add anything.
I'd take both :)
--
Stas Malyshev
smalyshev@gmail.com