[Python-Dev] UCS2/UCS4 default

Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Thu Jul 3 18:41:32 CEST 2008


-On [20080703 17:32], Paul Moore (p.f.moore at gmail.com) wrote:
>        System.out.println(s.length());

I think you want to use codePointCount() to count the Unicode code points.
length() returns Unicode code units.

As http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Character.html explains:

In the J2SE API documentation, Unicode code point is used for character
values in the range between U+0000 and U+10FFFF, and Unicode code unit is
used for 16-bit char values that are code units of the UTF-16 encoding.

-- 
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B
Man is the measure of all things...


More information about the Python-Dev mailing list