Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 08, 2009 @ 14:33
    Sebastiaan Janssen
    0

    XML encoding is utf-16 ?

    I'm trying to build some XML through an XSLT file, when I set:

    <xsl:output method="xml" omit-xml-declaration="no"/>

    Then I get the following in the resulting XML:</p> <pre><span class="pi"><?xml version="1.0" encoding="utf-16"?></span>

    However, my XML definition at the top of the XSLT file says:</p> <pre><span class="pi"><?xml version="1.0" encoding="utf-8"?></span>

    So, why am I getting utf-16? How do I change this to utf-8?

     

     

     

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 08, 2009 @ 14:34
    Sebastiaan Janssen
    0

    Argh.. it's messed up again... You get the point, right? ;-)

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Jul 08, 2009 @ 16:32
    Lee Kelleher
    102

    Hi Sebastiaan,

    You could try the following...

    Switch the omit-xml-declaration to "yes"

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    ... and then include the UTF-8 XML declaration as CDATA?

    <xsl:text disable-output-escaping="yes"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]></xsl:text>

    Let me know if that works.

    Cheers, Lee

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Jul 08, 2009 @ 16:38
    Lee Kelleher
    2

    The reason for the UTF-16 encoding is due to how .NET maintains characters internally within the framework.

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Jul 08, 2009 @ 17:06
    Sebastiaan Janssen
    0

    Works great Lee, thanks!

    And good to hear that there is a reason.

  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Jul 08, 2009 @ 17:08
    Lee Kelleher
    0

    You're welcome. Glad it worked!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies