Unicode + SVG problem

Discussion in 'XML' started by Klaubator, Jun 1, 2004.

  1. Klaubator

    Klaubator Guest

    Hi,

    A simple task is driving me crazy, just can figure out how to
    programatically write unicode characters to a SVG (XML) document.

    With an editor it is easy to write Unicode characters like &#x431
    (Cyrillic) to an SVG text element.

    Trying to do the same with code is a pain but there must be some
    solution.

    I've tried to do it with vb.net using both InnerHtml, InnerText and
    CDATA but the ampersand is always encoded as & just can figure out
    how to add an unencoded ampersand. Tried to do the same through the
    Adobe SVG plugins Javascript method setData() but the result was the
    same. The only solution I've come up with is using XSLT
    transformations or simply postprocess the XML/SVG contents as plain
    text but this is definitely not something I would want to do.

    There must be a solution to this simple task ?!

    Regards
    KL
    Klaubator, Jun 1, 2004
    #1
    1. Advertising

  2. Klaubator wrote:


    > A simple task is driving me crazy, just can figure out how to
    > programatically write unicode characters to a SVG (XML) document.
    >
    > With an editor it is easy to write Unicode characters like &#x431
    > (Cyrillic) to an SVG text element.
    >
    > Trying to do the same with code is a pain but there must be some
    > solution.
    >
    > I've tried to do it with vb.net using both InnerHtml, InnerText and
    > CDATA but the ampersand is always encoded as & just can figure out
    > how to add an unencoded ampersand. Tried to do the same through the
    > Adobe SVG plugins Javascript method setData() but the result was the
    > same. The only solution I've come up with is using XSLT
    > transformations or simply postprocess the XML/SVG contents as plain
    > text but this is definitely not something I would want to do.
    >
    > There must be a solution to this simple task ?!


    If you do DOM programming of XML documents then usually you don't need
    to escape Unicode characters as the DOM operates directly on the Unicode
    text data so you can simply use a string with the characters you want
    and insert them into a text node with DOM methods. The only problem are
    programming languages where strings are not Unicode encoded but VB.NET
    or JavaScript shouldn't be a problem. For instance with JavaScript
    textNode.setData(String.fromCharCode(0x431))
    or directly
    textNode.setData('б')
    should do

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 1, 2004
    #2
    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. Arne Nordmann
    Replies:
    0
    Views:
    511
    Arne Nordmann
    Jun 28, 2004
  2. Mardagg
    Replies:
    0
    Views:
    794
    Mardagg
    May 12, 2006
  3. Mardagg
    Replies:
    0
    Views:
    645
    Mardagg
    May 12, 2006
  4. milof83

    svg to svg saving problem

    milof83, Aug 18, 2006, in forum: Java
    Replies:
    1
    Views:
    806
    Roland de Ruiter
    Aug 18, 2006
  5. Helmut Jarausch

    Re: svg-chart 1.1 SVG Charting Library

    Helmut Jarausch, May 20, 2008, in forum: Python
    Replies:
    0
    Views:
    461
    Helmut Jarausch
    May 20, 2008
Loading...

Share This Page