<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
HI,<br>
<br>
This seems like a reasonable idea.<br>
For CharSequence, I would add them as default methods on
CharSequence <br>
and include the API Character.codePointCount(csq, begin, end)).<br>
The char array version will still need to be in Character.<br>
<br>
Regards, Roger<br>
<br>
<div class="moz-cite-prefix">On 8/11/25 7:37 PM, Uchino Tatsunori
wrote:<br>
</div>
<blockquote type="cite" cite="mid:TYVPR01MB11356224F9CB1EF0786E2E6829128A@TYVPR01MB11356.jpnprd01.prod.outlook.com">
<div dir="auto">
<div dir="auto">Dear Chen-san,</div>
<div dir="auto"><br>
</div>
<div dir="auto">The beginIndex there is just a mistake that must
have been removed. </div>
<div dir="auto"><br>
</div>
<div dir="auto">String.codePointCount()</div>
<div dir="auto"><br>
</div>
<div dir="auto">is the correct suggestion, as you can imagine. I
am sorry for the confusion.<br>
<div dir="auto"><br>
</div>
<div dir="auto">Regards, </div>
<div dir="auto"><br>
</div>
<div dir="auto">Tatsunori Uchino</div>
</div>
<div><br>
<div class="elided-text">2025/08/12 7:29 Chen Liang
<a class="moz-txt-link-rfc2396E" href="mailto:chen.l.liang@oracle.com"><chen.l.liang@oracle.com></a>:<br type="attribution">
<blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
Hi Uchino, I think your request is sensible in
general.</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
Do you intend to require a beginIndex for the
codePointCount for String? I think a no-arg version
suffices.</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
Also forwarding this to i18n-dev as it is the
locale-related list.</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
P.S. When you reply, make sure you click "Reply all"
so all the recipients of this current mail gets your
reply. Otherwise, the reply is only sent to me, and
others on the list won't see your reply.</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div style="font-family:'calibri light' , 'helvetica light' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
Regards, Chen</div>
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b>
core-libs-dev <a class="moz-txt-link-rfc2396E" href="mailto:core-libs-dev-retn@openjdk.org"><core-libs-dev-retn@openjdk.org></a>
on behalf of Uchino Tatsunori <a class="moz-txt-link-rfc2396E" href="mailto:tats.u@live.jp"><tats.u@live.jp></a><br>
<b>Sent:</b> Monday, August 11, 2025 6:54 AM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:core-libs-dev@openjdk.org">core-libs-dev@openjdk.org</a>
<a class="moz-txt-link-rfc2396E" href="mailto:core-libs-dev@openjdk.org"><core-libs-dev@openjdk.org></a><br>
<b>Subject:</b> I'd like add no-argument overloads
to CharSequence, String, and StringBuilder
(JDK-8364007)</font>
<div> </div>
</div>
<div><font size="2"><span style="font-size:11pt">
<div>Dear core-libs developers,<br>
<br>
I'd like to add the following overloads:<br>
<br>
• Character.codePointCount(CharSequence seq)<br>
• Character.codePointCount(char[] a)<br>
• String.codePointCount(int beginIndex)<br>
• StringBuffer.codePointCount()<br>
• StringBuilder.codePointCount()<br>
<br>
and created a patch (<a href="https://github.com/openjdk/jdk/pull/26461" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk/pull/26461</a>).<br>
<br>
Why:<br>
<br>
There have already been similar overloads with
the start and end indicies by JSR 204
(JDK-4985217). They are thought to have been
designed with a priority on versatility. They
make the specification of indices mandatory, but
have the following disadvantages:<br>
<br>
1. The string expression have to be written
twice. Unlike C#, Java has no equivalent of
extended methods.<br>
2. Unneccesary boundary checks are mixed in.<br>
3. The most userland code tries to calculate the
number of code points in the entire stirng.<br>
4. Some other languages can count the number of
code points in a single function without extra
arguments (e.g. len() in Python3)<br>
<br>
For 3., e.g.:<br>
<br>
• VARCHAR in MySQL & PostgreSQL counts the
number of characters in the unit of code points.
e.g. VARCHAR(20) means that the limit is 20 code
points, not 20 UTF-16 code units (20 chars in
Java)<br>
• NIST Special Publication 800-63B stiplates
that the password length must be counted as the
unit of code points. (Quote from
<a href="https://pages.nist.gov/800-63-3/sp800-63b.html#-5112-memorized-secret-verifiers" moz-do-not-send="true" class="moz-txt-link-freetext">
https://pages.nist.gov/800-63-3/sp800-63b.html#-5112-memorized-secret-verifiers</a>
: "For purposes of the above length
requirements, each Unicode code point SHALL be
counted as a single character.")<br>
<br>
I would like to get agreement on these changes
and would like to know what I have to do outside
of GitHub (e.g how to submit CSRs). If you have
a GitHub account, it would be helpful if you
could reply to the PR. If not, you can reply
directly to this email.<br>
<br>
Best Regards,<br>
<br>
Tatsunori Uchino <br>
<a href="https://github.com/tats-u/" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/tats-u/</a></div>
</span></font></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</body>
</html>