Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Bob Myers
Consider a language such as Kannada, spoken in sourthern India, and the 25th most widely spoken language in the world, with 60M speakers. "Characters" in the written language are represented in Unicode as elements (sometimes called "letters") which are then composed at the rendering level to

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Mathias Bynens
Prior discussion from 7 years ago: https://esdiscuss.org/topic/how-to-count-the-number-of-symbols-in-a-string [...string].length does what you want. But it's definitely not always what you need . On Thu, Aug 8, 2019 at

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Tab Atkins Jr.
On Thu, Aug 8, 2019 at 2:45 AM Claude Pache wrote: > 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

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Claude Pache
> Le 8 août 2019 à 11:07, fanerge 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

回复: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread fanerge
Thank you for your reply,I know that there are ways to get the right results, but I still think that there should be such a method on the prototype chain of String, rather than by other means (mostly by converting to an array to find the length). I hope that members of ECMA can consider it.

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread Claude Pache
> Le 8 août 2019 à 04:37, fanerge a écrit : > > I expect to be able to add an attribute to String.prototype that returns the > number of codePoints of the string to reflect the actual number of characters > instead of the code unit. Note however that “the number of code points” is not the

Re: Proposal: `String.prototype.codePointCount`

2019-08-08 Thread kdex
So what's wrong with `Array.from(str).length`? On Thursday, August 8, 2019 4:37:07 AM CEST fanerge wrote: > I expect to be able to add an attribute to String.prototype that returns the > number of codePoints of the string to reflect the actual number of > characters instead of the code unit. >