Re: n00bie - Use of ANSI and/or UniCode Characters ......

From: Dale King (kingd[at]tmicha[dot]net)
Date: 02/07/04


Date: Sat, 7 Feb 2004 17:57:04 -0500


"Boudewijn Dijkstra" <usenet@bdijkstra.tmfweb.nl> wrote in message
news:4023dabc$0$41758$5fc3050@dreader2.news.tiscali.nl...
> "ImperatorBush" <bk-dd@t-online.de> schreef in bericht
> news:bvvo53$8ba$04$1@news.t-online.com...
> > Hallo all,
> > I have (very) recently started learning to use Java, I have the SunJava2
> > 1.4.2/NetBeans 3.5.1 pack installed, and I have mostly been using
> > command line functions - or 'JCreator LE'(IDE) - for compiling/running
> > the classes - all works just fine!
> > My problem came up as I wanted to use the European currency symbol
> > '?'/Euro/ANSI 128 or hex0080 - as you may well see the character has
> > been typed and is (hopefully) displayed at your end - I just cannot
> > 'persuade' my programm to correctly display
> >
> > "System.out.print((char)128)" as a "?" on sysout.
>
> I hope you have already learned that Java is platform-independant, from
> which you can draw the conclusion that it probably doesn't assume
> Windows-1252 encoding in your source code.
>
> In Java, all characters are by definition Unicode characters. If you want
> to use the Euro-character, use the proper code point for it, which is
> U+20A0. As a char that is '\u20A0', in a String it is "Preis: \u20A0
2,95".

Note U+20A0 is not the official euro symbol. 20A0 was intended to be the
euro symbol, but was changed later. The real Euro symbol is U+20AC.

> Unfortunately, Sun's Java Virtual Machine doesn't always properly convert
> Unicode characters to platform default characters. Run this code and see
> what happens:

Yes, it does properly convert to the platform default characters. Some
things that can complicate this process on Windoze is that the platform
default encoding is Cp1252 which is the Windoze encoding. But the command
line window is often set to the DOS codepage which is different. That is a
problem with Windoze/DOS not Java.

--
 Dale King


Relevant Pages

  • Re: n00bie - Use of ANSI and/or UniCode Characters ......
    ... all characters are by definition Unicode characters. ... The real Euro symbol is U+20AC. ... it does properly convert to the platform default characters. ...
    (comp.lang.java.help)
  • Re: Just venting (totally OT)
    ... invisible characters in when only one is needed'. ... The problems is simply that you are using incompetent software, ... Windoze software because not all Windoze applications can read all ... Not that it took a Mac to do the conversions such that two different ...
    (uk.people.support.depression)
  • Re: Converting "&#x2019;" to an Apostrophe?
    ... euro symbol, double quote, etc.) to their ASCII equivalents? ... Maria's problem is expressed a bit vaguely but let's assume that her XML ... struggle to think up or locate ASCII equivalents for some of these. ... UTF-8 characters properly? ...
    (comp.lang.perl.misc)
  • Re: Could someone run this program on a pc which does not have a standard english configuration
    ... is set vary widely from platform to platform. ... the native-language characters, ... I tried running the code on 3 Linux distributions (SuSE, Redhat, ... It may be that the 'native codeset' was the same. ...
    (comp.std.c)
  • Re: SED Usage
    ... Because it is coming from another platform, ... > Character and then subsequent unprintable characters after ... > thru hex FE), is in fact catching more than desired. ... * To join/leave the list, search archives, change list settings, * ...
    (comp.sys.hp.mpe)