All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.jdbcproc.daofactory.impl.parameterconverter.ParameterConverterUtils Maven / Gradle / Ivy

There is a newer version: 1.1-35
Show newest version
package com.googlecode.jdbcproc.daofactory.impl.parameterconverter;

class ParameterConverterUtils {
    static String filter3BytesUTF(String value) {
        if (value == null) {
            return null;
        }

        if (!has4ByteChars(value)) {
            return value;
        }

        StringBuilder builder = new StringBuilder(value.length());

        for (int i = 0; i < value.length(); i++) {
            char c = value.charAt(i);
            if (!Character.isSurrogate(c)) {
                builder.append(c);
            }
        }

        return builder.toString();
    }

    private static boolean has4ByteChars(String value) {
        for (int i = 0; i < value.length(); i++) {
            if (Character.isSurrogate(value.charAt(i))) {
                return true;
            }
        }

        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy