The same special character, why is the number of bits displayed in edge and ie different?

广凯 李 20 Reputation points
2023-05-29T01:16:01.1166667+00:00

In the same html code, the maxlength of input is fixed y. Why can't edge continue to enter after entering some special characters, while ie can continue to enter one or two half-width characters.

Please give me some help.

Microsoft Edge | Microsoft Edge development
{count} votes

Accepted answer
  1. Anonymous
    2023-05-29T07:37:01.47+00:00

    Hi @广凯 李,

    Thanks for your code example. I have performed a test accordingly. What I have discovered is modern browsers all behave in the same way as Microsoft Edge that "𠀋" (and other characters belonging to "Supplementary Ideographic Plane") takes up two code units.

    This is because the HTML5 spec says that maxlength applies to the JavaScript string length which is the number of UTF-16 code units. So codepoints beyond 0xFFFF like Emojis and Supplementary Ideographic Plane count as two code units. So, it is an expected behavior in Edge and other modern browsers.

    As to IE, it has retired and is officially out of support. it is not a browser for HTML5.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Shijie Li

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.