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

Discussion in 'XML' started by Iain, Dec 15, 2003.

  1. Iain

    Iain Guest

    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.
     
    Iain, Dec 15, 2003
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Dec 15, 2003
    #2
    1. Advertising

  3. Iain

    Iain Guest

    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.
     
    Iain, Dec 15, 2003
    #3
    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. Ian Gregory
    Replies:
    1
    Views:
    517
  2. kellner
    Replies:
    0
    Views:
    883
    kellner
    Jul 23, 2006
  3. Trans

    [ANN] libxml and libxslt CVS

    Trans, Apr 2, 2005, in forum: Ruby
    Replies:
    2
    Views:
    132
    Andres Salomon
    Apr 7, 2005
  4. Trans
    Replies:
    8
    Views:
    140
    Trans
    Dec 6, 2005
  5. Iain
    Replies:
    1
    Views:
    156
    Martin Honnen
    Dec 15, 2003
Loading...

Share This Page