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 7834833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:20:48+00:00 2026-06-02T13:20:48+00:00

I have a problem on trimming whitespaces in Chinese characters. I tried to log

  • 0

I have a problem on trimming whitespaces in Chinese characters. I tried to log the content and here is how it looks like:

Result

When displaying it in textview, it does display Chinese characters but the problem is the whitespace before and after the string text. Can someone help me to encode/decode this? thanks in advance.

EDIT 1 : Added screenshot of result.

EDIT 2 : Added content charset in response.

HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

but I still get the square characters when logging and when displaying in XML layout, the square characters become whitespaces.

EDIT 3 : Added my working solution.

    private String removeWhiteSpace(String oldString) {
    String newString = null;
    if (oldString.length() > 0) {
        Character c = oldString.charAt(0);

        boolean isWhiteSpace = Character.isWhitespace(c);                           
        if (isWhiteSpace) {
            newString = oldString.replace(c, ' ');
        } else {
            newString = oldString;
        }

        newString = newString.trim();
    }
    return newString;
}
  • 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-02T13:20:50+00:00Added an answer on June 2, 2026 at 1:20 pm

    Chinese and Japanese don’t use the regular space character ‘ ‘. The languages use their own that is the same width as the characters. This is the character here ‘ ’, you should write a manual trim function to check for that character at the beginning and end of the string.

    You may be able to directly use the character if you convert your code file to unicode (if java will allow). Otherwise you will need to find the unicode character code for ‘ ’ and check if the character code is at the beginning or end of the string.

    The following link tells us that the ideographic space is 0xe38080 in UTF-8 and 0x3000 in UTF-16, and that Java’s Character.isSpaceChar() function will return true. I would have thought String.trim() would have used this property to determine whether or not to trim though.

    http://www.fileformat.info/info/unicode/char/3000/index.htm

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

Sidebar

Related Questions

I have a weird trimming problem here. I have a txt file of about
I have problem like this https://dev.twitter.com/discussions/4563 if (webResponse.Headers[Content-Encoding] == gzip) { byte[] bytes =
I have problem with Activities navigation, searching works good. Activities hierarchy looks like that:
Hello I have a problem with trimming string in c++. It adds some weird
I have problem with Uploadify: I log in the project using: FormsAuthentication.SetAuthCookie(myName, false); Then,
I have problem with the CSS. I'm changing dynamically one div's content. The problem
Here, I have a problem in the value from trim() function in PostgreSQL :
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar
I have problem with my query on C, I’m using the oci8 driver. This

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.