Class: EncodeUtils

EncodeUtils

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

decodeUmlauts(target, doAlsoEncodeUpperCase){String|Object}

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 using JSON.parse() (may lead to errors if umlauts occur in "strange" places within the stringified object).

encodeUmlauts(target, doAlsoEncodeUpperCase){String|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 using JSON.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)