
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