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

广凯 李 20 Reputation points

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
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,234 questions
{count} votes

Accepted answer
  1. ShiJieLi-MSFT 8,726 Reputation points Microsoft Vendor

    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