public static String addUtf8Charset ( String contentType ) { if ( contentType == null ) { return "text/plain;charset=utf-8" ; } Matcher matcher = CHARSET_PATT . matcher ( contentType ) ; if ( matcher . find ( ) ) { // replace what ever content-type with utf8 return contentType . substring ( 0 , matcher . start ( 1 ) ) + "utf-8" + contentType . substring ( matcher . end ( 1 ) ) ; } return contentType + ";charset=utf-8" ; }
Adds the utf - 8 charset to a content type .