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
"es-discuss"; 主题: Re: Proposal: `String.prototype.codePointCount` 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

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. >

Proposal: `String.prototype.codePointCount`

2019-08-07 Thread fanerge
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. Definition of String.prototype.length This property returns the number of code units in the string.