Javascript utf-8 substring and length function

I am trying to make substr in a UTF-8 string, like हिन्दी.

The problem is that in the end it completely twists => with some strange box (it doesn’t appear here, although I copied it) (something like [00 02]): हिन ...

In order, it appears after using the substr function:

alt text http://img27.imageshack.us/img27/765/capturexv.png

I wonder if there is any function to solve this problem? At least I want to remove this funny box.

Thank you for your time.

+3
source share
3 answers

JavaScript UTF-16, . .

wikipedia, , 0xD800-0xDBFF , , ( 0xDC00-0xDFFF) .

+2

, UTF-8, . .

0

UTF-8 JavaScript. JavaScript Unicode Unicode ( UTF-8).

I assume that you were able to cut the string in the middle of the character so that the result is incomplete. The browser will then try to display it anyway, which will lead to the release of moji.

0
source

Source: https://habr.com/ru/post/1719156/


All Articles