473,387 Members | 1,863 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,387 software developers and data experts.

accented characters

I cannot get accented charecters in my HTML output...
I have tried to leave the accented characters in and to use iso-8859-1,
but there it doesn't work either.
I have tried to use à entity, but & is a reserved character.
I have tried to use à or ß but the entity is not
recognised, and I get as an output in the browser "à" or "&#223"...
Maybe there is sometheing missing in the header...

This is a sample of my xml text
(the documents is a .php, for the purpuse of getting a variable from a
post...)
----------------
<?
header("Content-type: text/xml");
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<?xml-stylesheet type="text/xsl" href="inf-dev.xslt"?>';
?>

<inferno>
<filtro><?=$_POST[filter]?></filtro>
<canto>
<n>1</n>
<passo>
<vv>1</vv>
<dante>
<v>Nel mezzo del cammin di nostra vita</v>
</dante>
<carson>
<v>Halfway through the story of my life</v>
</carson>
<nota>
<n>Carson introduces story</n>
</nota>
</passo>
<passo>
<vv>14</vv>
<dante>
<v>là dove terminava quella valle é</v>
</dante>
<carson>
<v>hill; here, the valley formed a cul-de-sac</v>
</carson>
<nota>Carson introduces cul-de-sac, often associated to the
alleys of Belfast; local
colour</nota>
</passo>
</canto>
</inferno>
-----------------------
This is the XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html"/>
<xsl:template match="/">

<html>
<xsl:variable name="filter"><xsl:value-of
select="inferno/filtro"/></xsl:variable>
<head>

<title>Inferno: comparazione</title>
<link rel="stylesheet" title="main" href="stile-inf.css"
type="text/css" />

</head>
<body>
<div id="container">

<h1>Inferno</h1>

<h3>Filtro: <xsl:value-of select="inferno/filtro"/></h3>

<xsl:for-each select="inferno/canto">
<div class="cant">
<h2>
Canto <xsl:value-of select="n"/>
</h2>
<xsl:for-each select="passo">

<xsl:if test="contains(nota,$filter)">
<div class="pass">
<table border="0" width="100%">
<tr>
<td colspan="2">
<div class="vv">
<xsl:value-of select="../n"/>,
<xsl:value-of select="vv"/>
</div>
</td>
</tr>
<tr>
<td width = "50%">
<div class="dant">
<xsl:for-each select="dante/v">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</div>
</td>
<td>
<div class="cars">
<xsl:for-each select="carson/v">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="note">
<xsl:for-each select="nota">
- <xsl:value-of select="."/>
<br/>
</xsl:for-each>
</div>
</td>
</tr>
</table>
</div>

<br/>

</xsl:if> <!--CHIUSURA TEST-->
</xsl:for-each>

</div>
</xsl:for-each>

</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

any suggestion?
Thanks,
Davide
Jul 20 '05 #1
4 1764
I have tried to leave the accented characters in and to use iso-8859-1,
If you are typing the characters in iso-8859-1 then you can just type
them directly from your keyboard and then use
<?xml version="1.0" encoding="iso-8859-1"?>'
In theory an xml parser is not forced to accept iso-8859-1" encoding but
in practice it will.

You are using
<?xml version="1.0" encoding="UTF-8"?>
which any XML parser will accept but in that case you would want to type
your characters using utf8 encoding. (How to do this would depend on the
system that you are using)

If you want to keep your files as being essentially ascii and use
character references to access non ascii characters then you can use
either UTF-8 or iso-8859-1 as they are the same in the ascii range.

but then you want to use & # 2 2 4 ;

(without spaces)
I have tried to use &agrave; entity, but & is a reserved character. entities must be defined before use, so if you have not specified a DTD
that defines agrave to be some character you will get an undefined
entity reference error.
I have tried to use &amp;agrave;
By quoting the & you are just specifying the string"& a g r a v e ;" You
are explictly specifying that this is _not_ a reference to teh agrave
entity.
or &amp;#223;


similarly this is just the string "& # 2 2 3 ;" not a character
reference.
You want to use & not &amp; so that you get a character reference
(but 223 is sz you want 224 for a grave)

David
Jul 20 '05 #2
David Carlisle wrote:
which any XML parser will accept but in that case you would want to type
your characters using utf8 encoding.


Not quite. You need to _save_ them using UTF-8.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #3
Thanks a lot for yor careful explanation.
Unfortunately my problem persists.
Yet, maybe I am focusing...
The xsl transformation works correctly on Oxygen, my XML editing
software; à è é ì ò ù are all parsed correctly.
Yet when I open the XML page in the browser (Safari on Mac Os X) the
accented vowels turn into strange symbols.
I need to use my xml document inside the browser, since I use it to
generate dynamic content...
For some obscure reason the document doesn't work at all with Firefox
and Camino; yet it is a very simply structured xml document... When
opened with this browsers (both of them use the gecko rendering engine)
I get an error message saying that the xsl document can't be found (but
I assure you it is there!)
I am afraid something is missing in the prolog; I attach again the
prologue of xml and xsl files.
As I specified before, the xml file is actually a php file resulting
into an xml document
XML:

<?
header("Content-type: text/xml");
print '<?xml version="1.0" encoding="iso-8859-1"?>';
print'<!DOCTYPE inferno SYSTEM
"file:/Users/davidebenini/Documents/Universita%CC%80/Dottorato/inferno/inferno.dtd">';
print '<?xml-stylesheet type="text/xsl" href="inf-dev.xslt"?>';
?>
AND HERE THE ACTUAL XML CONTENT FOLLOWS

XSL:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

Any suggestion is welcome.
Thanks again
Jul 20 '05 #4
For some obscure reason the document doesn't work at all with Firefox


Note that mozilla/firefox is much stricter about mime types and http
headers than IE. I notice that you have given your stylesheet a .xslt
extension, what mime type is it hat servered with from your server?
It will need to be an XML one otherwise mozilla will not use it as a
stylesheet.
Also notice that although youhave a dtd reference mozilla/firefox never
loads an external dtd so if that dtd is needed to define entities or
attribute defaults, these will not work in mozilla.

In either case (mozilla or iE) the encodings specified by the server in
the http headers overrule the encodings specified in <?xml ...

So your php code is writing
<?xml version="1.0" encoding="iso-8859-1"?>';
and sending the header header("Content-type: text/xml"); I don't really
know php, if that's the only header that is sent then you should be OK
as the default encoding for text/xml is iso-8859-1 so as long as your
characters really are in that encoding it should just work...

Yet when I open the XML page in the browser (Safari on Mac Os X) the
accented vowels turn into strange symbols.

If these symbols include accented capital A's that's usually a sign that
the file is in utf8 but is being read as latin1, try manually puting the
browser in utf8 encoding (view/encoding menu in IE)

David
Jul 20 '05 #5

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

Similar topics

1
by: Bernhard Georg Enders | last post by:
I'm using the php 'file' command to read the contents of an ASCII text file to a variable. The original text file contains some accented and special characters. The problem arises when I echo this...
1
by: Fuzzyman | last post by:
I've written an anagram finder that produces anagrams from a dictionary of words. The user can load their own dictionary. ( http://www.voidspace.org.uk/atlantibots/nanagram.html ) In order to...
14
by: Nicolas Bouillon | last post by:
Hi I would like to replace accentuel chars (like "é", "è" or "à") with non accetued ones ("é" -> "e", "è" -> "e", "à" -> "a"). I have tried string.replace method, but it seems dislike...
2
by: Remco van den Berg | last post by:
I'm running a MySQL database with one of tables holding the members of a volleybal club in the Netherlands. One the the fields in that table is holding the name of the players. How do I search...
2
by: nicolas_riesch | last post by:
I try to use python as the language in an asp page with Microsoft IIS 5.0. I have these two files, req_bad.asp and req_ok.asp ---------- req_bad.asp --------- <%@LANGUAGE=Python%> <%
4
by: Satish | last post by:
Hi Gurus, Please help me in this, I have tried all options available to me. (Option 1) I am making a simple request from VB.NET client to WBI generated WSDL and passing request parameters. The...
0
by: shintu | last post by:
Hallo, I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !: My code: use strict;...
2
by: gsuns82 | last post by:
Hi all, I have to replace accented characters from a input string with normal plain text.I have coded as follows. String input = "ÄÀÁÂÃ"; input=...
4
by: gsuns82 | last post by:
Hi all, I am facing a strange issue. i.e: I have a jsp page with an input text field where the user can enter searching value even along with Accented Characters.After that i...
1
by: gsauns | last post by:
I have an ASP.NET app in which I import from a comma-delimited text file, put all that data in a GridView, and then insert the records into multiple related tables in my SQL Server database. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.