Here you can find the source of substringByCodePoint(String inputStr, int codePointStart, int codePointEnd)
Parameter | Description |
---|---|
inputStr | a parameter |
codePointStart | a parameter |
codePointEnd | a parameter |
public static String substringByCodePoint(String inputStr, int codePointStart, int codePointEnd)
//package com.java2s; public class Main { /**//from w ww. ja va 2 s .c o m * Returns a substring of the input string based on the input code points * * @param inputStr * @param codePointStart * @param codePointEnd * @return */ public static String substringByCodePoint(String inputStr, int codePointStart, int codePointEnd) { int charOffsetStart = convertCodePointOffsetToCharOffset(inputStr, codePointStart); int charOffsetEnd = convertCodePointOffsetToCharOffset(inputStr, codePointEnd); return inputStr.substring(charOffsetStart, charOffsetEnd); } /** * Computes the character offset for the specified code point offset in the * input string * * @param inputStr * @param codePointOffset * @return the character offset for the specified code point offset */ public static int convertCodePointOffsetToCharOffset(String inputStr, int codePointOffset) { return inputStr.offsetByCodePoints(0, codePointOffset); } }