Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display unicode in SVG?

Tags:

unicode

svg

An information stored in SVG format in the database.
If the data contains text it will be displayed as Unicode.

It is necessary to correctly display the SVG files in the browser.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="header" 
viewBox="654.0519483 -714.4517 356.4000564 252">
<defs></defs><g id="0" visibility="visible">
<text id="gText_11081308229940" name="-1" x="790.251953" y="-631.9517"  
font="Arial"  rotate="0" horizAnchor="middle" vertAnchor="middle" scale="4,4" width="1"            stroke="0x000000"> 
\u0048\u0045\u004C\u004C\u004F\u0020\u0057\u004F\u0052\u004C\u0044\u0021\u0021\u0021\u0021        </text> 
</g></svg>

When I try this code I get displayed Unicode instead of letters.

like image 363
adelak Avatar asked Oct 02 '13 10:10

adelak


People also ask

How do I display Unicode?

Inserting Unicode characters To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X.

How do I show Unicode in HTML?

You can enter any Unicode character in an HTML file by taking its decimal numeric character reference and adding an ampersand and a hash at the front and a semi-colon at the end, for example &#8212; should display as an em dash (—). This is the method used in the Unicode test pages.

What is Unicode attribute?

The unicode attribute specifies one or more Unicode characters indicating the sequence of Unicode characters which corresponds to a glyph. If a character is provided, then this glyph corresponds to the given Unicode character.

What is Unicode Hex code?

Unicode characters are distinguished by code points, which are conventionally represented by "U+" followed by four, five or six hexadecimal digits, for example U+00AE or U+1D310.


1 Answers

If you really want to insert Unicode values rather than just choosing the right encoding and putting the characters directly in there, use entities like you would in any other XML document:

    <text id="gText_11081308229940" name="-1" x="790.251953" y="-631.9517" font="Arial" rotate="0" horizAnchor="middle" vertAnchor="middle" scale="4,4" width="1" stroke="0x000000">&#x0048;&#x0045;&#x004C;&#x004C;&#x004F;&#x0020;&#x0057;&#x004F;&#x0052;&#x004C;&#x0044;&#x0021;&#x0021;&#x0021;&#x0021;</text>

Example.

like image 108
robertc Avatar answered Sep 22 '22 18:09

robertc