Tagged articles
string length
29 articles · Page 1 of 1
This guide explains how to enable the mbstring extension, use the mb_strlen() function with optional encoding, and apply practical examples—including Chinese and Japanese strings and length validation—to reliably handle multibyte strings in PHP development.
PHPcodingmb_strlen
0 likes · 4 min read


ITPUBDec 2, 2025 · Frontend Development
When debugging a web app, the author discovered that certain emojis occupy more than one character slot in JavaScript strings, revealing that emoji length varies because they are composed of multiple Unicode code points such as variation selectors and zero‑width joiners.
JavaScriptUnicodeemoji
0 likes · 4 min read

Learn how PHP’s built‑in strlen function works to return the byte length of a string, see a clear example with code, understand its output, and discover important considerations about character encoding and multibyte strings to ensure accurate length calculations.
PHPencodingstring length
0 likes · 3 min read

This article explains how to use PHP's mb_strlen function to accurately measure the length of multibyte strings such as Chinese or Japanese, covering installation of the mbstring extension, syntax, optional encoding, practical code examples, and common validation scenarios.
BackendPHPmbstring
0 likes · 4 min read

This article explains PHP's strlen() function, its syntax, and provides clear code examples showing how to calculate string lengths—including handling spaces and encoding considerations—for practical use cases like input validation.
Backendphp-functionsstring length
0 likes · 3 min read

This article explains PHP's built‑in strlen() function, demonstrates its usage with a complete code example, discusses the output, and highlights important considerations about byte‑based length versus character count for multibyte strings.
BackendPHPstring length
0 likes · 3 min read

This article explains PHP's strlen() function, detailing its syntax, demonstrating how to calculate string lengths with and without spaces, and highlighting important considerations such as encoding support and special characters in various applications.
PHPcodingstring length
0 likes · 4 min read

This article explains how to use PHP's built‑in strlen function to obtain the length of a string, demonstrates the code with a "Hello World!" example, discusses byte‑versus‑character counting, and highlights considerations for multibyte encodings.
PHPbackend developmentcoding tutorial
0 likes · 4 min read

This article explains how to enable the mbstring extension in PHP and use the mb_strlen function with UTF-8 encoding to accurately measure the length of multibyte strings, including practical code examples and techniques for checking empty strings.
PHPmb_strlenmultibyte
0 likes · 4 min read

This article explains how to enable the mbstring extension and use PHP's mb_strlen() function with optional encoding parameters to accurately measure the length of multibyte strings such as Chinese and Japanese, including practical code examples for length calculation and validation.
BackendPHPmbstring
0 likes · 5 min read

This article explains PHP's strlen() function, its syntax, demonstrates how to calculate string lengths with and without surrounding spaces using code examples, and discusses important considerations such as encoding support and handling of special or multibyte characters.
BackendPHPcoding
0 likes · 4 min read

This article explains how PHP's built‑in strlen function works to return the byte length of a string, demonstrates its usage with sample code, discusses the difference between byte and character counts, and highlights considerations for multibyte encodings.
PHPcoding tutorialstring length
0 likes · 4 min read

This article explains the PHP strlen() function, its syntax, and provides multiple code examples for measuring string length, checking for empty strings, validating length limits, and handling multibyte characters, while noting the need for mb_strlen() for Unicode strings.
Code ExamplePHPstring length
0 likes · 5 min read

This article explains how the PHP strlen() function works to determine the length of a string, provides a sample code snippet that assigns a string to a variable, calculates its length, and discusses important considerations such as byte versus character counting and encoding issues.
PHPcodingstring length
0 likes · 3 min read

This article explains PHP's strlen() function, detailing its syntax, demonstrating how to calculate string lengths—including handling spaces and trimming—and highlighting important considerations such as character encoding and special characters, with clear code examples and output explanations.
Backendcodingstring length
0 likes · 3 min read

This article explains how the PHP strlen() function works to determine the length of a string, provides a clear example with code, discusses the difference between byte and character counts, and highlights important considerations regarding character encoding when using strlen in backend development.
Backendcodingstring length
0 likes · 4 min read

This article explains how PHP's built‑in strlen() function works to calculate a string's length, provides a clear example with code, discusses its byte‑based return value and the implications for multibyte characters, and offers practical guidance for using it correctly in backend development.
Backendprogrammingstring length
0 likes · 3 min read

This article explains how to enable the mbstring extension in PHP and use the mb_strlen function to accurately measure multibyte string lengths, including examples with UTF-8 encoding, handling empty strings, and combining with trim for robust string validation.
Backendmbstringmultibyte
0 likes · 5 min read

This article explains PHP's strlen() function, detailing its syntax, return value, and providing multiple code examples that demonstrate how to obtain a string's length, check for emptiness, enforce length limits, and handle multibyte characters, while noting the use of mb_strlen() for Unicode strings.
BackendTutorialstring length
0 likes · 4 min read

This article explains why JavaScript string length behaves unexpectedly with Unicode characters, describes UTF‑16 encoding and surrogate pairs, and demonstrates ES6 techniques such as for‑of loops, spread syntax, the u regex flag, codePointAt, and normalize to handle Unicode correctly.
ES6JavaScriptUTF-16
0 likes · 7 min read

This article explains how to use PHP's mb_strlen() function from the mbstring extension to accurately measure the length of multibyte strings, covering installation, syntax, optional encoding parameters, practical examples in Chinese and Japanese, and how to validate string length limits.
PHPmbstringmultibyte
0 likes · 5 min read

This article explains how the PHP mb_strlen() function from the mbstring extension can accurately calculate the length of multibyte strings such as Chinese or Japanese, shows its syntax, optional encoding parameter, and provides practical code examples for length checking and validation.
BackendPHPcoding
0 likes · 5 min read

This article explains PHP's strlen() function, detailing its syntax, parameters, and behavior, and provides two practical code examples showing how to obtain string lengths with and without surrounding spaces, while noting encoding and special‑character considerations.
PHPcoding tutorialstring length
0 likes · 4 min read

This article explains the PHP strlen() function, covering its basic syntax, required parameter, return value, and provides two code examples that demonstrate how to obtain the length of regular strings and strings containing special characters or escape sequences.
PHPbackend developmentstring length
0 likes · 2 min read

This article explains the fundamentals of character sets and encodings—including ASCII, GB2312, GBK, Unicode, UTF‑8, UTF‑16, and UCS‑2—shows how they affect JavaScript string length, emoji handling, and common pitfalls such as combining characters, endianness, and BOM issues.
JavaScriptUTF-8Unicode
0 likes · 31 min read

This article explains why JavaScript's string length property returns unexpected values for Unicode characters like emojis, explores UTF‑16 encoding rules, and demonstrates modern ES6 techniques—including for‑of loops, spread syntax, and the \u{…} and /u regex flags—to correctly handle Unicode strings.
ES6JavaScriptUTF-16
0 likes · 9 min read

This article explains why strings containing emojis report different lengths in JavaScript, covering Unicode fundamentals, code points, UTF‑8 and UTF‑16 encodings, surrogate pairs, grapheme clusters, zero‑width joiners, and modern ES2015‑ESNext features that help handle Unicode correctly.
JavaScriptUTF-16UTF-8
0 likes · 15 min read

The mb_strlen() function in PHP returns the number of characters in a string, correctly handling multibyte characters and allowing an optional encoding parameter, with examples showing differences from strlen() under various encodings.
encodingmb_strlenstring length
0 likes · 2 min read

This article explains how Java stores characters as UTF‑16 code units, why the char type cannot cover the entire Unicode range, how surrogate pairs work, and demonstrates the differences in length, byte length, and char array size for regular Chinese characters, emojis, and rare Chinese glyphs.
Code PointJavaSurrogate Pair
0 likes · 9 min read
