Android String Sub String Get unicodePreservingSubstring(String paramString, int paramInt1, int paramInt2)

Here you can find the source of unicodePreservingSubstring(String paramString, int paramInt1, int paramInt2)

Description

unicode Preserving Substring

Declaration

public static String unicodePreservingSubstring(String paramString,
            int paramInt1, int paramInt2) 

Method Source Code

//package com.java2s;

public class Main {
    public static String unicodePreservingSubstring(String paramString,
            int paramInt1, int paramInt2) {
        int i = unicodePreservingIndex(paramString, paramInt1);
        int j = unicodePreservingIndex(paramString, paramInt2);
        return paramString.substring(i, j);
    }//ww  w.  ja v a  2  s  .co  m

    public static int unicodePreservingIndex(String paramString,
            int paramInt) {
        if (paramInt > 0) {
            int i = paramString.length();
            if (paramInt < i) {
                int j = paramInt + -1;
                if ((Character.isHighSurrogate(paramString.charAt(j)))
                        && (Character.isLowSurrogate(paramString
                                .charAt(paramInt))))
                    paramInt += -1;
            }
        }
        return paramInt;
    }
}

Related

  1. substring(String str, int beginIndex, int endIndex)
  2. substringAfter(String str, String separator)
  3. substringAfterLast(String str, String separator)
  4. substringBefore(String str, String separator)
  5. substringBeforeLast(String str, String separator)
  6. unicodePreservingSubstring(String str, int begin, int end)
  7. unicodePreservingSubstring(String str, int begin)
  8. substringAfter(String str, String separator)
  9. substringBetween(String str, String open, String close)