public static String substrb(String input, int n, String charsetName) {
        if (n <= 0) {
            return "";
        }

        byte[] bytes;
        try {
            bytes = input.getBytes(charsetName);
        }
        catch (UnsupportedEncodingException e) {
            throw new BaseException(e);
        }

        if (n >= bytes.length) {
            return input;
        }

        byte[] data = new byte[n]; // 结果

        int x = 0;
        int y = 0;
        while (x < n) {
            int length = Character.toString(input.charAt(y)).getBytes().length;
            if (length > 1) { // 双字节
                if (x >= n - 1) { // 如果是最后一个字节
                    break;
                }

                data[x] = bytes[x];
                data[x + 1] = bytes[x + 1];
                x += 2;
                y++;
            }
            else {
                data[x] = bytes[x];
                x++;
                y++;
            }
        }
        try {
            return new String(data, 0, x, charsetName);
        }
        catch (UnsupportedEncodingException e) { // 冗余
            throw new BaseException(e);
        }
    }