473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xml and java euro signs disapear

flm
I've got an XML document that contains euro signs and looks like :

<?xml version="1.0" encoding="utf-8"?>
<merchant id="52">
<product
offerid="03543068131"
deliverycost="6,90 "
/>
....

I use this bit of Java (jdk 1.4.2) code to parse it :

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( file_ );

The problem is the euro signs are transformed into the charactere '?'
(printing the value of a getAttribute( "deliverycost" ) gives ? on a
utf-8 terminal)

Thanks for any help,
FL

Jul 20 '05 #1
7 2062

You have declared that your xml file is utf-8 encoded but have used (as
far as I can tell) a byte with value 128 to represent a euro which isn't
the utf8 encoding of character 8364 which is the Euro.
You either need to declare the encoding that you are using or express
the character in an encoding-neutral form such as
"& # 8364 ;"
(without the spaces

David
Jul 20 '05 #2
Thank for you reply David.
If I use & # 8364; or even & # x20ac like you recommand I got the same
result.

FLM

*** Sent via Developersdex http://www.developersdex.com ***
Jul 20 '05 #3
"flm" <fl*******@hotmail.com> writes:
The problem is the euro signs are transformed into the charactere '?'
(printing the value of a getAttribute( "deliverycost" ) gives ? on a
utf-8 terminal)


The problem is in "printing", probably because your Writer object has
improper encoding and/or mismatching locale. Or because you use
System.out, which use the locale-specified encoding, which may not be
utf-8. It's probably best to give an explicit encoding/charset.

-- Alain.
Jul 20 '05 #4


Francois-Louis Mommens wrote:
If I use & # 8364; or even & # x20ac like you recommand I got the same
result.


Are you sure that output terminal is able to render a Euro symbol
properly? What happens if you do not use XML at all but try to output a
Euro symbol '' from a normal string?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #5
Hi there
flm wrote:
I've got an XML document that contains euro signs and looks like :

<?xml version="1.0" encoding="utf-8"?>
<merchant id="52">
<product
offerid="03543068131"
deliverycost="6,90 ?"
/>
...

I use this bit of Java (jdk 1.4.2) code to parse it :

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse( file_ );

The problem is the euro signs are transformed into the charactere '?'
(printing the value of a getAttribute( "deliverycost" ) gives ? on a
utf-8 terminal)


If you want to post an UTF-8 file, use UTF-8 as charset; Set the default
charset in your browser / newsreader to UTF-8.

Set your locale to UTF-8, eg en_GB.UTF-8 or en_US.UTF-8
Set de default characterset of your editor to UTF-8.
Use an UTF-8 enabled terminal such as uxterm.
Install unicode fonts such as Cyberbit.ttf, Ariel-unicode or GNU-unifont
and install a unicode font as your default font.
Regards,
Rob
--
+----------------------------------------------------------------------+
| The EU constitution will turn the EU into an USA colony |
| Vote against the EU constitution in the referendum |
+----------------------------------------------------------------------+
Jul 20 '05 #6
Hi there
Rob van der Putten wrote:
If you want to post an UTF-8 file, use UTF-8 as charset; Set the default
charset in your browser / newsreader to UTF-8.

Set your locale to UTF-8, eg en_GB.UTF-8 or en_US.UTF-8
Set de default characterset of your editor to UTF-8.
Use an UTF-8 enabled terminal such as uxterm.
Install unicode fonts such as Cyberbit.ttf, Ariel-unicode or GNU-unifont
and install a unicode font as your default font.


If all goes well, this should be UTF-8;

Nicer typography in plain text files:

╔═══════════════ ════════════════ ═════════╗
║ ║
║ • ‘single’ and “double” quotes ║
║ ║
║ • Curly apostrophes: “We’ve been here” ║
║ ║
║ • Latin-1 apostrophe and accents: '´` ║
║ ║
║ • ‚deutsche‘ „Anführungszeichen“ ║
║ ║
║ • *, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║
║ ║
║ • ASCII safety test: 1lI|, 0OD, 8B ║
║ *─────────╮ ║
║ • the euro symbol: │ 14.95 € │ ║
║ ╰─────────╯ ║
╚═══════════════ ════════════════ ═════════╝

Russian:

From a Unicode conference invitation:

Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
Конференция соберет широкий круг экспертов по вопросам глобального
Интернета и Unicode, локализации и интернационализации, воплощению и
применению Unicode в различных операционных системах и программных
приложениях, шрифтах, верстке и многоязычных компьютерных системах.

Greek:

From a speech of Demosthenes in the 4th century BC:

Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.

Δημοσθένους, Γ´ ᾿Ολυνθιακὸς

All the display, editing and conversion software you use should also be
capable of handling UTF-8.
Regards,
Rob
--
+----------------------------------------------------------------------+
| The EU constitution will turn the EU into an USA colony |
| Vote against the EU constitution in the referendum |
+----------------------------------------------------------------------+
Jul 20 '05 #7
Hi there
Martin Honnen wrote:
Are you sure that output terminal is able to render a Euro symbol
properly? What happens if you do not use XML at all but try to output a
Euro symbol '?' from a normal string?


Most UTF-8 enviroments display dec 128 / hex 0x80 as a glyph looking
something like;

+----+
| 00 |
| 80 |
+----+

The same applies to other glyphs in the 128 / 0x80 ... 159 / 0x9F range;

+----+
| 00 |
| 9F |
+----+

Maybe UTF-8 is somehow converterd to CP-1252.

Try yudit, http://www.yudit.org/ to view and edit your files.
Regards,
Rob
--
+----------------------------------------------------------------------+
| The EU constitution will turn the EU into an USA colony |
| Vote against the EU constitution in the referendum |
+----------------------------------------------------------------------+
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Zierhofer | last post by:
hi there, it seems as if i cant convert the euro and pound sign to their html equivalents. i tried eregi_replace("", "&euro;", $haystack); eregi_replace("", "&pound;", $haystack); as...
198
by: Michael N. Christoff | last post by:
Java, the software developed by Sun Microsystems in the mid-1990s as a universal operating system for Internet applications, gave NASA a low-cost and easy-to-use option for running Spirit, the...
11
by: Jos? Cardoso | last post by:
Hi, I have developed a java application that interacts with a database. Now i've the folowing problem: - I have a list retrieved from the database(about 200 records); - for each, i do a...
11
by: MH | last post by:
Thai may have been asked before but I'm new here.... How can I put the Euro symbol, ? using alt0128 in my page and get it validated as HTML 4.01 ? -------------- MH
18
by: gabriel | last post by:
greetings, I am currently working on a website where I need to print the Euro symbol and some "oe" like in "oeuvre". If I choose this : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
8
by: Max | last post by:
My client has decided to use the Euro for the entire web site. Is there an easy way to get my ASP.NET app to format currency to Euro instead of US-dollar? Right now it's just reading the server...
3
by: Georg Weiler | last post by:
Hi, I have a database PostgreSQL entry that includes the string € which is the euro sign. When I retrieve the string through a PHP SQL statement and then echo the result to the browser, it...
1
by: jemar19 | last post by:
import java.util.*; public class Kopi { static Scanner console=new Scanner(System.in); public static void main(Stringargs) { String f; double a,z,y,x,w;
5
by: JavaMas | last post by:
I am a beginner in Java programming after a few lessions I was provided with this task and I have no clue how to go about it.this appears to be simple but for me is a mountain, if any one could help...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.