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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:59:22+00:00 2026-05-26T17:59:22+00:00

I have the following code : System.out.println(new String(–’.getBytes(ISO8859_15_FDIS))); The two characters in the first

  • 0

I have the following code :

System.out.println(new String("–’".getBytes("ISO8859_15_FDIS")));

The two characters in the first String are:

  • – (96 in hex)
  • ’ (92 in hex)

The output of the code is:

??

Which is to be expected as the code page for ISO8859_15_FDIS shows that the two characters above are not in the printable part of the table.

What I would like to get is an acceptable mapping:

-'

(ie 2D and 27 in ISO8859_15_FDIS)

Is there a way to perform this conversion within the standard Java API, or am I just going to have to store some kind of explicit mapping (Map<Character,Character>) between the actual value and the wanted value?

For a bit of context, we have a Sybase database that is using this character set, and when users paste those characters into text areas on the fronting web app, they end up as question marks in the database.

  • 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-26T17:59:23+00:00Added an answer on May 26, 2026 at 5:59 pm

    Code like this is never correct:

    new String(string1.getBytes(ENC_1), ENC_2);
    

    The above code is always a transcoding bug.

    The correct way to transcode these code points from windows-1252 to ISO8859_15_FDIS is as follows:

    byte[] windows1252 = { (byte) 0x96, (byte) 0x92 };
    String utf16 = new String(windows1252, Charset.forName("windows-1252"));
    byte[] iso8859_15_FDIS = utf16.getBytes(Charset.forName("ISO8859_15_FDIS"));
    

    Java chars are always implicitly UTF-16 and all other encodings should be represented using byte arrays.

    However, ISO-8859-15 does not support the two code points (U+2013 and U+2019) so this will be a lossy process. The values you are expecting (U+002D and U+0027) have identical byte values in both encodings.

    These are just completely different code points and you will have to maintain some form of normalization routine to map characters that have visually similar graphemes.

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

Sidebar

Related Questions

Suppose we have the following code: class Test { private Test() { System.out.println(test); }
I have the following code: if (System.IO.File.Exists(htmlLocation)) { vEarthBrowser.ObjectForScripting = this; vEarthBrowser.Url = new
I got the following code: int nnames; String names[]; System.out.print(How many names are you
I have the following Java code: byte[] signatureBytes = getSignature(); String signatureString = new
I was interested to have the following getNumberOfDecimalPlace function: System.out.println(0 = + Utils.getNumberOfDecimalPlace(0)); //
I have the following code: <div> <% TaxonomicTypeFeed ttf = new TaxonomicTypeFeed(); ArrayList<String> tmp
I have the following code: using System; using System.Linq; using System.Linq.Expressions; public class Program
I have the following code: using System; using System.Diagnostics; using System.IO; using PdfSharp.Pdf.Printing; namespace
I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
i have the following code Private Sub select_color_Click(ByVal sender As System.Object, ByVal e As

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.