1

I have some svg which has some special characters in it. while parsing it into xml, getting the error. Here is the svg,

https://www.printhubpro.co.uk/images/export.svg

It has string like this in svg

ú (may be representing EURO)

Which causing issue.

I want to allow special character in svg. Any suggestion?

Himanshu Bhardiya
  • 1,047
  • 14
  • 37

1 Answers1

-1

The SVG you are trying to load is not valid. If you visit it in Chrome it won't render that bit at all.

error on line 22 at column 412: Encoding error

Entity encode your special characters before including them.

Chris
  • 5,571
  • 2
  • 20
  • 32
  • Yes it because special character in it like `ú`. thats the issue, i want to allow special character in svg. – Himanshu Bhardiya Apr 12 '16 at 07:37
  • @HimanshuBhardiya You can't just dump special characters in to an SVG (effectively an XML file). You have to entity encode them. https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references – Chris Apr 12 '16 at 07:39
  • any preferable solution? – Himanshu Bhardiya Apr 12 '16 at 07:50
  • @HimanshuBhardiya The solution is to not generate SVGs with special characters in them. You have to encode the characters properly. It is mandatory. If you don't, no SVG renderer can be expected to anything sensible with your file. – Chris Apr 12 '16 at 07:51
  • but svg is generating from canvas dynamically, as i am trying to encode using replace that text like this `$svg_op = str_replace('ú','£',$svg_op);` is not working, but if i replace `£` manually then its working. Am i doing anything wrong here? – Himanshu Bhardiya Apr 12 '16 at 08:01
  • @HimanshuBhardiya Try this instead: `$svg_op = str_replace("\xA3","£",$svg_op);` – Chris Apr 12 '16 at 08:18
  • -1 for being a link-only answer. You should include that the Euro symbol can be displayed in the document using the string `€`. – Jeff G Apr 02 '20 at 23:55