1.5中String新增加了public int codePointCount(int beginIndex,int endIndex)方法,请问有知道如何使用的吗?

解决方案 »

  1.   

    看看这个吧:
    private String testString = "abcd\u5B66\uD800\uDF30";
    int charCount = testString.length();
    int characterCount = testString.codePointCount(0, charCount);
    System.out.printf("character count: %d\n", characterCount);
          This example prints this:character count: 6      
          The testString variable contains two interesting characters, which are a Japanese character meaning "learning" and a character named GOTHIC LETTER AHSA. The Japanese character has Unicode code point U+5B66, which has the same hexadecimal char value \u5B66. The Gothic letter's code point is U+10330. In UTF-16, the Gothic letter is the surrogate pair \uD800\uDF30. The pair represents a single Unicode code point, and so the character code point count of the entire string is 6 instead of 7.
      

  2.   

    请问存在数据库中是按String.length()还是String.codePointCount()存的呢?