Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the constant HTTP.UTF_8 deprecated?

After upgrading to Apache HttpClient >=4.2, I found the following constant now deprecated:

org.apache.http.protocol.HTTP.UTF_8

Why was this constant deprecated (along with others) and what is the Apache HttpClient recommended alternative? The a HttpCore javadoc here lists it as deprecated but does not recommend an alternative.

like image 250
Peter Porter Avatar asked Jun 09 '14 20:06

Peter Porter


1 Answers

Since Java 7, Java provides the StandardCharsets class for getting the Charset object for a few standard character sets. These are: ASCII, ISO-8859-1, UTF-8, UTF-16, UTF-16BE, and UTF-16LE. That's the alternative.

There's no longer a point in re-declaring the String name of the character set in an HTTP class.

like image 127
Sotirios Delimanolis Avatar answered Oct 21 '22 11:10

Sotirios Delimanolis