Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7837957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:55:46+00:00 2026-06-02T14:55:46+00:00

I have httpservice on android device. It forms response as html page to some

  • 0

I have httpservice on android device. It forms response as html page to some browser. So it works fine but if I use other languages (for example Russian), server returns unreadable text instead of Russian symbols. I know that default encoding on Android is UTF-8. I’ve tried every encoding available on the Android (For example windows-1251, Big5(Chinese), UTF-16 and so on) but it returned wrong result at all. Here is some code which show you what I’ve tried to do:

@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {

 HttpEntity entity = new EntityTemplate(new ContentProducer() {
            public void writeTo(final OutputStream outstream) throws IOException {

                OutputStreamWriter writer = new OutputStreamWriter(outstream, "windows-1251");
                String resp = "<html><body>Hello Привет</body></html>";
                StringEntity se = new StringEntity(resp, "windows-1251");
                se.writeTo(outstream);
                //writer.write(resp);
                //writer.flush();
            }
        });
    response.setHeader("Context-Type", "text/html");                    
    response.setEntity(entity);
}

So in browser I see next:

Hello Привет

What do I wrong? Please, answer me.
I’ll appreciate for any suggestions. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:55:48+00:00Added an answer on June 2, 2026 at 2:55 pm

    You may try using java.text.Normalizer or add <meta http-equiv="Content-Type" content="text/html charset=UTF-8" /> to your response.

    Besides, I’d recommend you not to hardcode strings, but put them to resources and load them with Resources.getString(resId) instead – thus you would have potentially less problems with encodings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a httpservice on my android device. So I send a single file
I want to use an HTTPService to load some data (number of columns and
I have a httpservice that returns xml data. <mx:HTTPService id=httpService url=data/Software.xml resultFormat=e4x result=httpResult_handler(event) fault=Alert.show('XML
I retrieve XML data in Flex via HttpService. I have the resultFormat property on
I have an HTTPservice id=myhttp url=site.com/script.php method=POST resultFormat=xml The script it uses returns $output
I have an httpservice object instantiated and have defined an event listener to handle
I have this ArrayCollection filled with a xml data coming from and HttpService request.
I have a Flex client making RESTful calls to a webservice using HTTPService. The
I have some JSPs that I'd like to split out into another bundle/WAB and
I have a TextArea and I'm trying to use HTTPRequest to fetch a website

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.