question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing XML (encoding ISO-8859-1) with Retrofit2 and SimpleXmlConverter doesn't show correct characters

See original GitHub issue

We (@deen13 and myself) are using the SimpleXmlConverter and Retrofit in our project like this:

private final MealplanService service = new Retrofit.Builder()
            .baseUrl("IP-ADDRESS")
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build()
            .create(MealplanService.class);

    @Override
    public void fetch(DownloadFinished downloadFinished) {
        Call<Mealplan> call = service.getMealplan();

        call.enqueue(new Callback<Mealplan>() {
            // handling the response with response.body()
        });
    }

The response from the server is ISO-8859-1 encoded (confirmed by sniffing the http traffic and response in the browser) but is interpreted as UTF-8 as all “ä, ö, ü” characters are displayed as “�, �, �”.

We’ve tried using an interceptor, cloning the SimpleXmlConverter class and manually setting the encoding to ISO-8859-1 (where we found out that the Response object is already messed up) and setting the header parameters manually but nothing seems to work.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JakeWhartoncommented, Dec 19, 2017

Sounds like a win-win.

On Tue, Dec 19, 2017 at 3:10 AM Florian notifications@github.com wrote:

This IS a bug, the Response is not parsed correctly by your library. Strange that once we converted to Volley, everything worked just fine huh?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/retrofit/issues/2589#issuecomment-352669666, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEW2fzRDBK6I2AkA4MhSFOqYvtbBYks5tB294gaJpZM4RFBVP .

2reactions
swankjessecommented, Dec 19, 2017

Thanks for your question. This issue tracker is only for bug reports with test cases and feature requests. Please ask usage questions on Stack Overflow. https://stackoverflow.com/questions/tagged/retrofit

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing XML (encoding ISO-8859-1) with Retrofit2 and ...
Parsing XML (encoding ISO-8859-1) with Retrofit2 and SimpleXmlConverter doesn't show correct characters in Android.
Read more >
Parsing XML (encoding ISO-8859-1) with Retrofit2 ... - GitHub
Parsing XML (encoding ISO-8859-1) with Retrofit2 and SimpleXmlConverter doesn't show correct characters #2041.
Read more >
XML encoding to iso88591 - webMethods
All, I want the encode the xml I sent with iso-8859-1. ... When you set this to true it will convert special characters...
Read more >
Parsing XML using Retrofit2 in Kotlin - Ekaterina Temnogrudova
With inline set to true, it is determined that the elements of the Collection are inlined. That means, that they have no enclosing...
Read more >
How to set the Xml Encoding ISO-8859-1 to Transformer or ...
Is there any way I can maintain the original Xml Encoding of ... Builder parser does not like this character when encoding is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found