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

TypeError in Strings::toAscii() #216

Closed
strider2038 opened this issue Mar 5, 2020 · 10 comments
Closed

TypeError in Strings::toAscii() #216

strider2038 opened this issue Mar 5, 2020 · 10 comments

Comments

@strider2038
Copy link

Version: 3.1.1

Bug Description

iconv() https://github.com/nette/utils/blob/master/src/Utils/Strings.php#L167 returns false on some strings

TypeError: Return value of Nette\Utils\Strings::toAscii() must be of the type string, bool returned in /app/services/core/vendor/nette/utils/src/Utils/Strings.php on line 183

Steps To Reproduce

Original bug occurs when package was updated from 3.1.0 to 3.1.1 as a dependency for Easy Coding Standards library deprecated-packages/symplify#1787

The problem occurs on Linux Alpine Docker image.

Expected Behavior

No type error

@dg
Copy link
Member

dg commented Mar 5, 2020

On which string it returns false`

@strider2038
Copy link
Author

/app/services/core - this is project directory. May be it is platform dependent?

@strider2038
Copy link
Author

strider2038 commented Mar 5, 2020

Also, there is warning

iconv(): Wrong charset, conversion from 'UTF-8' to 'ASCII//TRANSLIT//IGNORE' is not allowed

@strider2038
Copy link
Author

It seems to be a problem with Linux Alpine image as it mentioned here nunomaduro/phpinsights#43 (comment)

But what about processing of iconv result? Is there any alternatives to iconv()? Or maybe check for false result can be added?

$converted = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s);
if ($converted !== false) {
    $s = $converted;
}

@dg
Copy link
Member

dg commented Mar 5, 2020

What is value of constant ICONV_IMPL?

@strider2038
Copy link
Author

value is unknown

@dg dg closed this as completed in 354fb50 Mar 5, 2020
@dg
Copy link
Member

dg commented Mar 6, 2020

Fixed

@strider2038
Copy link
Author

Thanks! It now works perfectly. When will be a release?

@dg
Copy link
Member

dg commented Mar 6, 2020

I think in about a week…

@strider2038
Copy link
Author

@dg Hello! What about a release?

dg added a commit that referenced this issue Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants