remove Ox.encodeHTML and Ox.decodeHTML; move Ox.encodeHTMLEntities and Ox.decodeHTMLEntities to HTML.js
This commit is contained in:
parent
b93750e325
commit
40d1d021d4
1 changed files with 0 additions and 54 deletions
|
@ -235,60 +235,6 @@ Ox.decodeDeflate = function(string, callback) {
|
||||||
image.src = 'data:image/png;base64,' + btoa(data);
|
image.src = 'data:image/png;base64,' + btoa(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
|
||||||
Ox.encodeHTML <f> HTML-encodes a string
|
|
||||||
> Ox.encodeHTML('\'<"&">\'')
|
|
||||||
''<"&">''
|
|
||||||
> Ox.encodeHTML('äbçdê')
|
|
||||||
'äbçdê'
|
|
||||||
@*/
|
|
||||||
Ox.encodeHTML = function(string) {
|
|
||||||
string = Ox.isUndefined(string) ? '' : string.toString();
|
|
||||||
return Ox.map(string, function(char) {
|
|
||||||
var code = char.charCodeAt(0);
|
|
||||||
return code < 128
|
|
||||||
? (char in Ox.HTML_ENTITIES ? Ox.HTML_ENTITIES[char] : char)
|
|
||||||
: '&#x' + Ox.pad(code.toString(16).toUpperCase(), 4) + ';';
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*@
|
|
||||||
Ox.decodeHTML <f> Decodes an HTML-encoded string
|
|
||||||
> Ox.decodeHTML(''<"&">'')
|
|
||||||
'\'<"&">\''
|
|
||||||
> Ox.decodeHTML(''<"&">'')
|
|
||||||
'\'<"&">\''
|
|
||||||
> Ox.decodeHTML('äbçdê')
|
|
||||||
'äbçdê'
|
|
||||||
> Ox.decodeHTML('äbçdê')
|
|
||||||
'äbçdê'
|
|
||||||
> Ox.decodeHTML('<b>bold</b>')
|
|
||||||
'<b>bold</b>'
|
|
||||||
@*/
|
|
||||||
Ox.decodeHTML = function(string) {
|
|
||||||
// relies on dom, but shorter than using this:
|
|
||||||
// http://www.w3.org/TR/html5/named-character-references.html
|
|
||||||
return Ox.decodeHTMLEntities(Ox.element('<div>').html(string).html());
|
|
||||||
};
|
|
||||||
|
|
||||||
Ox.encodeHTMLEntities = function(string) {
|
|
||||||
return string.replace(
|
|
||||||
new RegExp('(' + Object.keys(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
|
||||||
function(match) {
|
|
||||||
return Ox.HTML_ENTITIES[match];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Ox.decodeHTMLEntities = function(string) {
|
|
||||||
return string.replace(
|
|
||||||
new RegExp('(' + Ox.values(Ox.HTML_ENTITIES).join('|') + ')', 'g'),
|
|
||||||
function(match) {
|
|
||||||
return Ox.keyOf(Ox.HTML_ENTITIES, match);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.encodeUTF8 <f> Encodes a string as UTF-8
|
Ox.encodeUTF8 <f> Encodes a string as UTF-8
|
||||||
see http://en.wikipedia.org/wiki/UTF-8
|
see http://en.wikipedia.org/wiki/UTF-8
|
||||||
|
|
Loading…
Reference in a new issue