Class UnicodeUtil


  • public class UnicodeUtil
    extends java.lang.Object
    Unicode-related utility functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      UnicodeUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countLength​(java.lang.String str)
      Count the number of "character" in Unicode string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UnicodeUtil

        public UnicodeUtil()
    • Method Detail

      • countLength

        public static int countLength​(java.lang.String str)
        Count the number of "character" in Unicode string. "character" here is defined by http://www.w3.org/TR/REC-xml#NT-Char Basically, all the work this function will do is to take care of surrogate pairs. If string contains any char ('char' in Java datatype) other than those allowed in XML spec, the behavior is undefined. However, we can safely assume that XML parser performs this check before we receive the value.