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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:07:55+00:00 2026-05-24T01:07:55+00:00

I am reading data from xml. When I checked in eclipse console I found

  • 0

I am reading data from xml. When I checked in eclipse console I found I am getting the whole data with some square boxes. Example If there is 123 in excel sheet i am getting 123 with some square boxes. I used trim() to avoid such things but didnot get success because trim() method trims only white spaces. But I found those characters have ASCII value -17, -20 .. I dont want to trim only white spaces I want to trim those square boxes also

So I have used the following method to trim those characters and I got success.

What is the more appropriate way of trimming a string

Trimming a string

String trimData(String accessNum){
        StringBuffer sb = new StringBuffer();
        try{
            if((accessNum != null) && (accessNum.length()>0)){
//              Log.i("Settings", accessNum+"Access Number length....."+accessNum.length());
                accessNum = accessNum.trim();
                byte[] b = accessNum.getBytes();
                for(int i=0; i<b.length; i++){
                    System.out.println(i+"....."+b[i]);
                    if(b[i]>0){
                        sb.append((char)(b[i]));
                    }
                }
//              Log.i("Settigs", accessNum+"Trimming....");
            }}catch(Exception ex){

            }
            return sb.toString();
    }
  • 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-05-24T01:07:56+00:00Added an answer on May 24, 2026 at 1:07 am

    Edited

    use Normalizer (since java 6)

    public static final Pattern DIACRITICS_AND_FRIENDS 
            = Pattern.compile("[\\p{InCombiningDiacriticalMarks}\\p{IsLm}\\p{IsSk}]+");
    
    
    private static String stripDiacritics(String str) {
            str = Normalizer.normalize(str, Normalizer.Form.NFD);
            str = DIACRITICS_AND_FRIENDS.matcher(str).replaceAll("");
            return str;
    }
    

    And here and here are complete solution.

    And if you only want to remove all non printable characters from a string, use

    rawString.replaceAll("[^\\x20-\\x7e]", "")
    

    Ref : replace special characters in string in java and How to remove high-ASCII characters from string like ®, ©, ™ in Java

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

Sidebar

Related Questions

I'm reading some data from an XML format and putting it in my classes
I'm having some problems reading data from XML and load it into an array.
I'm reading XML data from the HttpServletRequest in my servlets doPost() and passing the
I'm reading data from XML files into a strong typed DataSet . The data
I am reading data from an xml doc and placing it on a web
I am having a xml file and i am reading the data from that
I am reading data from another system that returns XML that provides the following
Android 2.1 update 1 Eclipse 3.5 I have a problem reading data from my
I am trying reading in data from XML files using C# XMLTextReader. Most of
I'm having trouble reading in XML data from an XML resource located in /res/xml/testxml.xml.

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.