- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strlen() php function giving the wrong length of unicode characters ?
To get the correct length, use mb_strlen() for Unicode characters.
The PHP code is as follows −
Example
<?php $unicodeValues = 'JohnSmȉth'; echo "The string length with mb_strlen=",mb_strlen($unicodeValues, 'utf8'); echo "
"; echo "The string length with strlen=",strlen($unicodeValues); ?>
Output
The string length with mb_strlen=9 The string length with strlen=10
- Related Articles
- strlen() function in PHP
- What is strlen function in C language?
- Write a C program demonstrating strlen library function
- How do I print Unicode characters in the console using JavaScript?
- How to convert Unicode values to characters in JavaScript?
- How to use Unicode and Special Characters in Tkinter?
- Unicode codepoint escape syntax in PHP 7
- PHP – How to get the Unicode point value of a given character?
- What is IUPAC, giving its one function?
- PHP program to find the number of characters in the string
- How to check if a unicode string contains only numeric characters in Python?
- How to create a plot title with unicode characters using ggplot2 in R?
- Order strings by length of characters IN mYsql?
- Printing Unwanted Characters with PHP “preg_match”?
- How MySQL LENGTH() function measures the string length?

Advertisements