Adds fallback for mb_strlen, fixes #61#64
Conversation
There was a problem hiding this comment.
Let's follow WP coding standards here.
|
Thanks for the feedback @danielbachhuber . I've updated based on your comments. |
There was a problem hiding this comment.
How exactly is using plain substr() encoding-safe?
There was a problem hiding this comment.
I.e. if it was encoding-safe, people wouldn't have used mb_substr() in the first place, no?
There was a problem hiding this comment.
Demonstration:
<?php
$str = 'sécurité';
echo substr( $str, 0, 2 ) . "\n";
echo mb_substr( $str, 0, 2, mb_detect_encoding( $str ) ) . "\n";
Output:
s�
sé
|
@scribu I see your point. Plain Would it be safe to assume UTF-8 encoding in cases where Outputs: and could be used as a fallback for |
No, I don't think that's a safe assumption. |
|
However, I think Edit: Oh, it seems |
|
What I'd like to have for php-cli-tools is:
For WP-CLI, we can fall back to |
I spoke too soon. We don't use |
Since these functions are just used for displaying data, as opposed to manipulating data that will be sent to a database, I think that's acceptable. The function descriptions are still incorrect, though. |
I'll try to add that clarification in an update of the pull request that also includes @danielbachhuber recommendation for the |
|
Thanks @jesseoverright. I'd love to get this sorted out in the next couple of days so we can ship |
|
Sounds good. I'll submit an updated pull request tomorrow.
|
…extensions are missing and encoding is present
|
Function descriptions are updated. Also added Also included tests for |
Adds fallback for mb_strlen, fixes #61
|
👍 |
Adds a
function_existscheck formb_strlen()and will use php'sstrlen()in place ofmb_strlen(). Addresses issues with PHP installations that do not have the non-default mbstring extension enabled.