claude.pache at gmail.com
Thu Aug 8 09:45:12 UTC 2019
> Le 8 août 2019 à 11:07, fanerge <fanerge at qq.com> a écrit :
> There are many such requirements in a real development scenario, such as how many characters are allowed to be entered by the user, which is something we should consider not in Unicode for Basic Multilingual Plane.
I have cases where I want to limit the length of user input, for which purpose I just use <input maxlength>, although it gives inconsistent results across the three browsers I have tested: two of them limit the number of UTF-16 code units, one of them limits the number of grapheme clusters (and none of them limit the number of code points).
In fact, for my purpose, I have no reason to impose a limit for a precise number of *code points* (as opposed to other possible definitions of “length” such as *UTF-16 code units* or *grapheme clusters*). Technically, I am usually limited by the size of a column in the database, for which the “size” corresponds typically to the number of bytes in a UTF-8 encoded string. From a user point-of-view, the number of “characters” is better approximated by the number of grapheme clusters. None of those two notions of “length” correspond to the number of code points.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss