Is the default Java character encoding always Cp1252?

Discussion in 'Java' started by Mickey Segal, Apr 18, 2005.

  1. Mickey Segal

    Mickey Segal Guest

    I switched the default to Turkish on a Windows XP computer and found that
    the default character encoding in our Java applet is still the same as with
    US English - Cp1252. I tested using both the system property
    "File.encoding" and with OutputStreamWriter.getEncoding().

    Is Cp1252 always the default? Should one always specify UTF-8 if expecting
    users with a large variety of language defaults or are there better
    approaches?
    Mickey Segal, Apr 18, 2005
    #1
    1. Advertising

  2. Mickey Segal

    asaguden Guest

    No expert opinion, but
    A.F.A.I.K. Cp1252 is the default encoding on win platforms.
    That said - it is probably your windows IDE that has that setting.
    Try changing it there and recompile.
    asaguden, Apr 19, 2005
    #2
    1. Advertising

  3. Mickey Segal

    Mickey Segal Guest

    Our test Java code does not specify an encoding, yet we get Cp1252 when
    checking encoding, even when supposedly set to Turkish. It does not look
    like there is an IDE setting to specify an encoding, though we could do so
    in our code by using method forms such as OutputStreamWriter(OutputStream
    out, String enc) and choosing an encoding such as UTF-8.

    What I am confused about is whether Java is not seeing my computer as
    Turkish or instead that Java gives a default encoding of Cp1252 even to
    computers seen as Turkish. It would be good to know the answer so I would
    know if we are able to test and be treated as Turkish.

    In either case the answer may just be to specify UTF-8 explicitly, but for
    testing purposes it would be nice to know if we are really simulating the
    Turkish user.

    "asaguden" <> wrote in message
    news:...
    > No expert opinion, but
    > A.F.A.I.K. Cp1252 is the default encoding on win platforms.
    > That said - it is probably your windows IDE that has that setting.
    > Try changing it there and recompile.
    Mickey Segal, Apr 19, 2005
    #3
  4. Mickey Segal

    Mickey Segal Guest

    A further issue is character encoding for URLConnections. What encoding is
    used for the URL? More concretely, if you use code such as this for an open
    urlConnection object:

    OutputStream outputStream = urlConnection.getOutputStream();
    OutputStreamWriter outputStreamWriter = new
    OutputStreamWriter(outputStream, "UTF8");
    BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);
    bufferedWriter.write(query,0,query.length());
    bufferedWriter.flush();
    bufferedWriter.close();

    are you able to impose UTF-8 coding (or other encodings) or is the URL
    connection not able to pass along such an encoding?
    Mickey Segal, Apr 19, 2005
    #4
  5. Mickey Segal

    Bryce Guest

    On Tue, 19 Apr 2005 07:59:19 -0400, "Mickey Segal"
    <> wrote:

    >Our test Java code does not specify an encoding, yet we get Cp1252 when
    >checking encoding, even when supposedly set to Turkish. It does not look
    >like there is an IDE setting to specify an encoding, though we could do so
    >in our code by using method forms such as OutputStreamWriter(OutputStream
    >out, String enc) and choosing an encoding such as UTF-8.


    Check the system property "file.encoding"

    System.getProperty("file.encoding");

    In some instances, you may need to specify -Dfile.encoding=UTF8 at the
    command line.

    >What I am confused about is whether Java is not seeing my computer as
    >Turkish or instead that Java gives a default encoding of Cp1252 even to
    >computers seen as Turkish. It would be good to know the answer so I would
    >know if we are able to test and be treated as Turkish.
    >
    >In either case the answer may just be to specify UTF-8 explicitly, but for
    >testing purposes it would be nice to know if we are really simulating the
    >Turkish user.
    >
    >"asaguden" <> wrote in message
    >news:...
    >> No expert opinion, but
    >> A.F.A.I.K. Cp1252 is the default encoding on win platforms.
    >> That said - it is probably your windows IDE that has that setting.
    >> Try changing it there and recompile.

    >



    --
    now with more cowbell
    Bryce, Apr 20, 2005
    #5
  6. Mickey Segal

    Mickey Segal Guest

    "Bryce" <> wrote in message
    news:...
    > Check the system property "file.encoding"
    >
    > System.getProperty("file.encoding");


    This is one of the two ways I had checked the encoding, and found it to be
    Cp1252 despite the Turkish Windows settings. (The other way was by creating
    an OutputStreamWriter and checking its encoding).

    > In some instances, you may need to specify -Dfile.encoding=UTF8 at
    > the command line.


    That may explain why our testing always showed Cp1252. It sounds like we
    will need to do a lot of explicit specification of encoding. As pointed out
    (also by Bryce) in the "POSTing: can character encoding be specified?"
    thread it looks like we need to specify the URL "Content-Type" encoding for
    the data sent via URLConnection and need to set encoding explicitly in
    Readers and Writers.
    Mickey Segal, Apr 20, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Eppstein

    Distinguishing cp850 and cp1252?

    David Eppstein, Nov 3, 2003, in forum: Python
    Replies:
    3
    Views:
    597
    David Eppstein
    Nov 3, 2003
  2. Do Re Mi chel La Si Do

    To circumvent the bug cp1252

    Do Re Mi chel La Si Do, May 15, 2005, in forum: Python
    Replies:
    0
    Views:
    429
    Do Re Mi chel La Si Do
    May 15, 2005
  3. =?iso-8859-1?B?bW9vcJk=?=

    Cp1252 problem

    =?iso-8859-1?B?bW9vcJk=?=, Sep 27, 2006, in forum: Java
    Replies:
    2
    Views:
    41,121
    Mike Schilling
    Sep 27, 2006
  4. Méta-MCI

    Bug? import cp1252

    Méta-MCI, May 12, 2007, in forum: Python
    Replies:
    2
    Views:
    491
    Méta-MCI
    May 14, 2007
  5. Replies:
    12
    Views:
    398
    Dennis Lee Bieber
    Nov 18, 2012
Loading...

Share This Page