12

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.

4

2 回答 2

15

如果您真的想插入 Unicode 值,而不是仅仅选择正确的编码并将字符直接放入其中,请像在任何其他 XML 文档中一样使用实体:

    <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>

例子

于 2013-10-02T10:50:35.990 回答
3

只是为了任何未来的访客都会关心的情况。这个 \u0048 或这个 H 不是“一个 Unicode(s)”。Unicode 是解释如何将二进制值编码为要显示的字符的标准。上面的符号更准确地表示字符的 Unicode 转义序列。当您无法直接输入 Unicode 字符时,它们很有用。(在原始问题的示例中使用它们是没有意义的。)它们中有很多,你不应该混合它们。您可以查看此页面的示例:http: //billposer.org/Software/ListOfRepresentations.html

于 2016-06-24T08:18:24.543 回答