user
user

Reputation: 545

Encoding apostrophes in java

I have a String containing an RSS feed. My problem is that there is an encoding problem with the apostrophes. Here's what my String contains :

<entry>
            <title>67’s and Wolves trade defencemen</title>
            <summary type="text">The Ottawa’s 67’s and Sudbury Wolves swapped defencemen in a trade on Tuesday, with the 67’s /summary>
</entry>

As you can see, i got this ’ caracter everywhere, how i can resolve this ?

Thanks.

Upvotes: 0

Views: 1411

Answers (2)

cello
cello

Reputation: 5486

most likely the RSS feed is in UTF8, but you look at it with some other encoding. When creating FileInputStreams or some other streams in Java (but not all), you can specify the encoding that should be used to parse. Try StandardCharsets.UTF8 in Java 7 or 8 to specify the UTF-8 encoding.

Upvotes: 2

ControlAltDel
ControlAltDel

Reputation: 35096

First, you need to find the encoding of this string. Is it specified somewhere? Once that's accomplished, you can do

InputStream in = ...; // open a stream to your RSS feed
InputStreamReader reader = new InputStreamReader(in, streamFormat);

Upvotes: 2

Related Questions