473,698 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Encoding problems / Perl 5.8.0 / XML::LibXML / XML::LibXSLT

Folks,

I'm having a problem with charset encodings that I desparately need some
help with. I don't even pretend to know the basics about charsets, so
please forgive my ignorance.

I am transforming XML source into XHTML using an encoding of iso-8859-1
and when I browse (using Mozilla 1.x) I see strange, accented 'A'
characters preceeding some characters generated from an entity
reference. If I use utf-8, things get a lot worse: even my  
characters get prefixed with the accented junk.

My resultant XHTML source has the usual XML preamble at the top,
complete with encoding specification; however, it doesn't use <meta/> to
specify the charset -- could this be the cause of my problem?

Basically, because I don't understand this, and because I'd like to, can
someone recommend the practises I should be following when doing these
transforms, especially when using Perl and the XML::LibXML/XML::LibXSLT
to manage them.

Ideally, I'd like to use utf-8 (I'm guessing that's the best approach)
but it's been a bit of a non-started for me.

Hoping someone in c.t.xml or c.l.perl.misc can point me in the best
direction.

Many thanks,
Iain.
--
Blow the smoke from my address if replying personally.

Jul 20 '05 #1
2 2386


Iain wrote:
I'm having a problem with charset encodings that I desparately need some
help with. I don't even pretend to know the basics about charsets, so
please forgive my ignorance.

I am transforming XML source into XHTML using an encoding of iso-8859-1
and when I browse (using Mozilla 1.x) I see strange, accented 'A'
characters preceeding some characters generated from an entity
reference. If I use utf-8, things get a lot worse: even my &nbsp;
characters get prefixed with the accented junk.

My resultant XHTML source has the usual XML preamble at the top,
complete with encoding specification; however, it doesn't use <meta/> to
specify the charset -- could this be the cause of my problem?


What content-type do you send to the browser? If you have server side
scripting then you don't need a meta element but you should send a HTTP
header
Content-Type: text/html; charset=ISO-8859-1
to indidacte the encoding if you send text/html as the HTML parser of a
browser will hardly look at the XML declaration.
If you send the XHTML with an XML content type like
Content-Type: text/xml
then the browser will use the XML parser and that should indeed process any
<?xml version="1.0" encoding="ISO-8859-1"?>
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen wrote:
-->8--
What content-type do you send to the browser? If you have server side
scripting then you don't need a meta element but you should send a HTTP
header
Content-Type: text/html; charset=ISO-8859-1
to indidacte the encoding if you send text/html as the HTML parser of a
browser will hardly look at the XML declaration.
If you send the XHTML with an XML content type like
Content-Type: text/xml
then the browser will use the XML parser and that should indeed process any
<?xml version="1.0" encoding="ISO-8859-1"?>


Thanks Martin. The HTTP header did the trick.

Iain.
--
Clear the smoke from my address before replying directly to me.

Jul 20 '05 #3

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

Similar topics

0
1569
by: Matt Price | last post by:
Hello, I'm a python (& xml, & unicode!) newbie working on an interface to a bibliographic reference server (refdb); I'm running into some encoding problems & am ifnding the plethora of tools a little confusing. Here is the basic situation: I connect to the server and receive an xml document whose content is a bibliographic dataset. The document can be encoded in two ways: ISO-8859-1 or unicode. My program simply takes the document...
1
27702
by: Vlajko Knezic | last post by:
Not so sure what is going on here but is something to do with the way UTF8 is handled in Perl and/or LibXML The sctript below: - accepts a value from a form text field; - builds XML document around it,
0
1365
by: Markus Hoenicka | last post by:
Hi all, I'm trying to transform a simple test document to PDF using Passivetex. I'm not sure where to look for the error, but something in the toolchain doesn't cooperate, resulting in the following TeX error message: ! Missing number, treated as zero. <to be read again> p
1
1477
by: Joshua Sparks | last post by:
I have an XML source that I want to modify to use Unix Environment variables to represent directories instead of hard coding them. I'd like to know if this is possible...knowing that XML is platform independant. Thanks
5
1965
by: Warrick FitzGerald | last post by:
Hi Guys, I'm looking for a command line tool that I can manipulate an XML file with, using XSL. I don't want to use any form of java. I would like a stand alone tool. Could someone please suggest something. Thanks
0
1236
by: Alain Ketterlin | last post by:
Sorry to post this here, but I don't really have time to look for a more appropriate plae. I just upgraded libxml2/libxslt from xmlsoft.org, and get a crash on <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:com="http://whatever.com"
5
1784
by: bugbear | last post by:
I need to process some XML files that are rather large. However their structure may usefully be expressed as <ELEMENT FILE (RECORD)+> .. .. .. Each record is a few Kb. The files are many 10's of Megabytes.
3
6574
by: fionathomson | last post by:
Hi, I am using PHP version 4.4.0.0 and apache2 version 2.0.54. I am trying to install the xml dom support but am not having any luck. Following the instructions on php.net I have done the following:
16
1612
by: news | last post by:
I'm trying to parse an XML formatted post reply, and I can't figure out how to get the value of the right tag. The XML is formatted like this: <A> <foo>val1</foo> </A> <B> <foo>val2</foo> </B>
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.