RSS feed [root] /weblog /java /string




login:

password:

title search:




 


Tue Nov 08 10:35:42 GMT 2005

length



Surprisingly, String length more complicate than we excepted. A char is not necessarily a complete character, so if you need to know the character length, you need to use codePointCount method

int charLen = myString.length();
int characterLen = myString.codePointCount(0, charLen);

However, if you use UTF-8 encoding, string.length() will work as expected.

More detail see:
http://forum.java.sun.com/thread.jspa?threadID=671720


(google search) (amazon search)
second
download zip of files only