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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:38:41+00:00 2026-06-14T17:38:41+00:00

I have been unable to fix a problem with Java Unicode and encoding. The

  • 0

I have been unable to fix a problem with Java Unicode and encoding. The problem is that I have 5,000+ Strings like: “Steve O#8217Conord and Mirco Savas” and …”Rusell O&#146Connell” where “#8217” and “&#146” must be replaced with an apostrophe.

But there are many many different variants of this code and the apache.common.lang.StringUtils Apache library isn’t helping me solve the problem because the library needs the “&” char at the beginning and “;” at the end. I can’t input these everywhere because there are over 5,000 strings. So if there is any way using regex or something else to find these sequences in the strings and replace them with apostrophes, I’ll be glad to hear it 🙂

Additionally, there are some symbols like “O’” and they are a big problem because they should be read in UTF8. I mean like (\u8127) and other characters. Do you have any suggestions?

  • 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-14T17:38:42+00:00Added an answer on June 14, 2026 at 5:38 pm

    Try something like this:

    import java.io.FileOutputStream;
    import java.io.PrintWriter;
    import org.apache.commons.lang3.StringEscapeUtils;
    
    String[] myStringPool = {"Steve O#8217Conord and Mirco Savas","Rusell O&#146Connell"};
    PrintWriter pw = new PrintWriter("utf-8.txt", "UTF-8");
    for(String string : myStringPool) {
        pw.println(StringEscapeUtils.unescapeXml(string.replaceAll("&?#(\\d+);?", "&#$1;")));
    }
    pw.close();
    

    Assuming you already have these strings accesible, string.replaceAll("&?#(\\d+);?", "&#$1;") cleans up the XML entities in the strings to be unescaped by org.apache.commons.lang3.StringEscapeUtils (Get it here), the strings are finally written to a file in UTF-8 format.

    Note that Java can be configured to automatically read and write files as UTF-8. Java should automatically use the right encoding for your system. It is generally a bad idea to explicitly write files as a certain encoding, unless you really know what you are doing.

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

Sidebar

Related Questions

I have a strange problem in Fiddler that I have been unable to fix
I have been trying to fix this problem for hours. My app keeps crashing
I have a similar problem like mentioned in this question: Unable to create the
I have been unable to find any documentation on the .build method in Rails
I have been unable to find any decent documentation on this function. The code
I have been unable to find any documentation on properly closing database connections in
I have been unable to locate any information on compatibility with Visual Studio 2003
I have been researching intently and have been unable to find a solution to
I have need to return multiple results from a subquery and have been unable
After an extensive search I have been unable to find any information on 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.