Counting the number of multi-byte characters
-
27-02-2021 - |
문제
I have text containing multi-byte characters as shown:
위키백과, 백과사전.
대수(λ -, lambda -)는 함. 1930년대 다. 함수 s(x, y) = x*x + 입력 x 것이다. x ↦ x 와 y ↦ y 는 변수의 이름은. 또한 (x, y) ↦ x*x + y*y 와 (u, v) ↦ u*u + v*v 는.123456
In a word processor, it gives me a character count of 148.
On a HTML form encoded in UTF-8, it uses up a TEXTAREA
field with attribute of maxlength = 150
.
Using the PHP function mb_strlen($_POST['text'],'UTF-8')
, it returns a value of 152.
Which one is correct?
해결책
I'm going to say they all are correct.
With no line endings it is 148.
With line endings it is 150 or 152 depending on the encoding (Windows uses 2 characters per line ending).
제휴하지 않습니다 StackOverflow