mmir.tools.EncodeUtils
Utility for encoding/decoding (~ "masking"/"un-masking") character sequences,
e.g. special characters like umlauts.
Example
mmir.require(['mmirf/encodeUtils'], function(encodeUtils){
...
var encodedStr = encodeUtils.encodeUmlauts(str);
...
});
Methods
-
Decodes from
__{CHAR}[e|s]__
to umlauts, e.g.__ae__
toä
or__ss__
toß
Name Type Description target
String | Object the String for wich all contained umlauts-encoding should be replaced with the original umlauts. If this parameter is not a String, it will be converted using JSON.stringify()
and the resulting String will be processed (may lead to errors if umlauts occur in "strange" places within the stringified object).doAlsoEncodeUpperCase
Boolean optional OPTIONAL if true
, then upper-case umlauts-encodings will be decoded, too DEFAULT:false
(i.e. no decoding for upper-case umlauts-encodings)Returns:
Type Description String | Object the String with decoded umlauts-encodings (i.e. with the "original" umlauts). If the input argument target
was an Object, the return value will also be an Object, for which the processing stringified Object is converted back usingJSON.parse()
(may lead to errors if umlauts occur in "strange" places within the stringified object). -
Encodes umlauts to
__{CHAR}[e|s]__
, e.g.ä
to__ae__
orß
to__ss__
Name Type Description target
String | Object the String for wich all contained umlauts should be replaced with an encoded version. If this parameter is not a String, it will be converted using JSON.stringify()
and the resulting String will be processed (may lead to errors if umlauts occur in "strange" places within the stringified object).doAlsoEncodeUpperCase
Boolean optional OPTIONAL if true
, then upper-case umlauts will be encoded, too DEFAULT:false
(i.e. no encoding for upper-case umlauts)Returns:
Type Description String | Object the String with encoded umlauts. If the input argument target
was an Object, the return value will also be an Object, for which the processing stringified Object is converted back usingJSON.parse()
(may lead to errors if umlauts occur in "strange" places within the stringified object). -
htmlEncode(source, display, tabs){String}
-
HTML-Encode the supplied input Parameters:
Name Type Description source
String The text to be encoded. display
Boolean optional OPTIONAL The output is intended for display. If true (or undefined): * Tabs will be expanded to the number of spaces indicated by the 'tabs' argument. * Line breaks will be converted to
. If false: * Tabs and linebreaks get turned into ____; entities just like all other control characters.tabs
Number optional OPTIONAL The number of spaces to expand tabs to. (Ignored if the 'display' parameter evaluates to false or if tabs is not >= 0.) Default: undefined (do not replace tabs with spaces) Returns:
Type Description String the HTML encoded string version 2010-11-08 (modified: 2012-12-20)