protected String checkString ( String text ) throws UnexpectedLiquibaseException { if ( null == text || text . isEmpty ( ) ) { return text ; } final int len = text . length ( ) ; char current ; int codePoint ; for ( int i = 0 ; i < len ; i ++ ) { current = text . charAt ( i ) ; if ( Character . isHighSurrogate ( current ) && i + 1 < len && Character . isLowSurrogate ( text . charAt ( i + 1 ) ) ) { codePoint = text . codePointAt ( i ++ ) ; } else { codePoint = current ; } if ( ( codePoint == ' ' ) || ( codePoint == ' ' ) || ( codePoint == ' ' ) || ( codePoint == 0xB ) || ( codePoint == 0xC ) || ( ( codePoint >= 0x20 ) && ( codePoint <= 0x7E ) ) || ( ( codePoint >= 0xA0 ) && ( codePoint <= 0xD7FF ) ) || ( ( codePoint >= 0xE000 ) && ( codePoint <= 0xFFFD ) ) || ( ( codePoint >= 0x10000 ) && ( codePoint <= 0x10FFFF ) ) ) { //ok } else { throw new UnexpectedLiquibaseException ( INVALID_STRING_ENCODING_MESSAGE ) ; } } return text ; }
Catch any characters that will cause problems when parsing the XML down the road .