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

  • Home
  • SEARCH
  • 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 9188723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:04:57+00:00 2026-06-17T20:04:57+00:00

How do I set the character encoding in Apache HTTP Components? I do something

  • 0

How do I set the character encoding in Apache HTTP Components?

I do something like this:

    Form form = Form.form();
    form = form.add("somekey", "somevalue");
    Request request = Request.Post("http://somehost/some-form")
                             .request.bodyForm(form.build());

“somekey” and “somevalue” are unicode strings because all java string are unicode. http components converts them to latin-1 when I tested. I want it to convert to something else (e.g., utf-8).

  • 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-17T20:04:59+00:00Added an answer on June 17, 2026 at 8:04 pm

    Going by what you’ve shown in your example, you seem to be using the fluent API.

    Looking into the javadocs there is a version of request.bodyForm() that accepts a charset:

        import org.apache.http.Consts;
        ...
        request = request.bodyForm(form.build(), Consts.UTF_8);
    

    According to the source, the charset defaults to Consts.ISO_8859_1 (a.k.a. Latin-1).

    Alternatives

    1. If that doesn’t work, consider:

      import org.apache.http.Consts;
      ...
      request.elementCharset(Consts.UTF_8);
      
    2. As a last resort, it should be possible to set the content charset. Looking at the source for elementCharset(), you could try the following:

      import org.apache.http.Consts;
      import org.apache.http.params.CoreProtocolPNames;
      ...
      request.config(CoreProtocolPNames.HTTP_CONTENT_CHARSET, Consts.UTF_8);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for functional way to set default character encoding for HTTP responses for
I have an issue with character encoding: I have this page: http://www.studiomille.jp/class/ (its in
If I'm using utf-8 encoding for a character set that would use the character
Is there a python library for encoding ascii data to 7-bit GSM character set
This is my c++ struct (Use Multi-Byte Character Set) typedef struct hookCONFIG { int
In a large data set I have some data that looks like this: guide
The question is ,I hope,simple for someone who knows about character encoding. This is
Is there a way to set the character encoding of files generated by the
How can one set character encoding on external JavaScript files using only Websphere (5.1)?
Does anybody know if there is a simple way to detect character set encoding

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.