Skip to content

Conversation

@xanagi
Copy link
Contributor

@xanagi xanagi commented May 1, 2014

strlen() returns the number of bytes, not the number of characters.
This causes a problem when a multibyte string is supplied to string length validation.

mb_strlen() counts the number of characters, so is suitable for minLength/maxLength check.
I modified to use mb_strlen() when mbstring extension is loaded.

@xanagi xanagi changed the title Use mb_strlen instead of stlen when mbstring extension is available. Use mb_strlen instead of strlen when mbstring extension is available. May 1, 2014
@bighappyface
Copy link
Collaborator

👍

Great test character selection!

@xanagi
Copy link
Contributor Author

xanagi commented May 2, 2014

Thanks 😊

justinrainbow added a commit that referenced this pull request Aug 25, 2014
Use mb_strlen instead of strlen when mbstring extension is available.
@justinrainbow justinrainbow merged commit c587f9b into jsonrainbow:master Aug 25, 2014
hakre pushed a commit to hakre/json-schema that referenced this pull request Mar 26, 2015
Use mb_strlen instead of strlen when mbstring extension is available.
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

Successfully merging this pull request may close these issues.

3 participants