blob: 5af99b8a54857121db74fb2ce2c2adf9e995cafd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
License:
LGPL: http://www.gnu.org/licenses/lgpl.html
EPL: http://www.eclipse.org/org/documents/epl-v10.php
See the LICENSE file in the project's top-level directory for details.
Authors:
* Fabian Jakobs (fjakobs)
************************************************************************ */
/* ************************************************************************
#require(qx.lang.Object)
************************************************************************ */
/**
* Escaping and unescaping of XML strings.
*/
qx.OO.defineClass("qx.xml.String");
/**
* Escapes the characters in a <code>String</code> using XML entities.
*
* For example: <tt>"bread" & "butter"</tt> =>
* <tt>&quot;bread&quot; &amp; &quot;butter&quot;</tt>.
*
* Supports only the four basic XML entities (gt, lt, quot, amp).
* Does not support DTDs or external entities.
* Note that unicode characters greater than 0x7f are currently escaped to their numerical \\u equivalent.
*
* @see #unescape
*
* @param str {String} the string to be escaped
* @return {String} the escaped string
*/
qx.Class.escape = function(str) {
return qx.dom.String.escapeEntities(
str,
qx.xml.Entity.FROM_CHARCODE
);
};
/**
* Unescapes a string containing XML entity escapes to a string
* containing the actual Unicode characters corresponding to the
* escapes.
*
* Supports only the four basic XML entities (gt, lt, quot, amp).
* Does not support DTDs or external entities.
*
* @see #escape
*
* @param str {String} the string to be unescaped
* @return {String} the unescaped string
*/
qx.Class.unescape = function(str) {
return qx.dom.String.unescapeEntities(
str,
qx.xml.Entity.TO_CHARCODE
);
};
|