public static String encodeUTF8( final String s ) { try { return encode( s, "UTF-8" ); } catch ( UnsupportedEncodingException e ) { //ignore } return null; }
/** * Encodes the given value. The encoding process is skipped, if the value is null, is a number or is a date. * * @param fieldValue * the value that should be encoded. * @return the encoded value. */ private Object encode( final Object fieldValue ) { if ( fieldValue == null ) { return null; } if ( fieldValue instanceof Date ) { return fieldValue; } else if ( fieldValue instanceof Number ) { return fieldValue; } try { return URLEncoder.encode( String.valueOf( fieldValue ), encoding ); } catch ( UnsupportedEncodingException e ) { MessageFormatExpression.logger.debug( "Unsupported Encoding: " + encoding ); return null; } }
/** * Encodes the value read from the defined field. The value is converted to a string using the "toString" method. * * @return the value of the function. */ public Object getValue() { if ( field == null ) { return null; } final Object value = getDataRow().get( getField() ); if ( value == null ) { return null; } try { return URLEncoder.encode( String.valueOf( value ), encoding ); } catch ( UnsupportedEncodingException e ) { return null; } }
retval[i] = fieldValue; } else if ( isUrlEncodeValues() ) { retval[i] = URLEncoder.encode( String.valueOf( fieldValue ), encoding ); } else { retval[i] = fieldValue;
return URLEncoder.encode( result, getEncoding() ); } else { return result;
/** * Returns the formatted message. * * @return the formatted message. */ public Object getValue() { final ResourceBundleFactory resourceBundleFactory = getResourceBundleFactory(); messageFormatSupport.setFormatString( pattern ); messageFormatSupport.setLocale( resourceBundleFactory.getLocale() ); final String result; if ( isUrlEncodeValues() ) { final EncodeDataRow dataRow = new EncodeDataRow(); dataRow.setEncoding( encoding ); dataRow.setWrappedDataRow( getDataRow() ); result = messageFormatSupport.performFormat( dataRow ); } else { result = messageFormatSupport.performFormat( getDataRow() ); } if ( isUrlEncodeResult() ) { try { return URLEncoder.encode( result, getEncoding() ); } catch ( UnsupportedEncodingException e ) { MessageFormatExpression.logger.debug( "Unsupported Encoding: " + encoding ); return null; } } else { return result; } }
return new TypeValuePair( TextType.TYPE, URLEncoder.encode( s, encodingResult ) );
( TextType.TYPE, URLEncoder.encode( textResult, encodingResult ) );