tinymce.html.js
function(text, attr, entities) {
                entities = entities || namedEntities;
                return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
                    return baseEntities[chr] || entities[chr] || chr;
                });
            }
function(text, attr, entities) {
                entities = entities || namedEntities;
                return text.replace(attr ? attrsCharsRegExp : textCharsRegExp, function(chr) {
                    return baseEntities[chr] || entities[chr] || chr;
                });
            }
function ( text , attr , entities ) { entities = entities || namedEntities ; return text . replace ( attr ? attrsCharsRegExp : textCharsRegExp , function ( chr ) { return baseEntities [ chr ] || entities [ chr ] || chr ; } ) ; }
Encodes the specified string using named entities. The core entities will be encoded
as named ones but all non lower ascii characters will be encoded into named entities.

@method encodeNamed
@param {String} text Text to encode.
@param {Boolean} attr Optional flag to specify if the text is attribute contents.
@param {Object} entities Optional parameter with entities to use.
@return {String} Entity encoded text.
Encodes the specified string using named entities . The core entities will be encoded as named ones but all non lower ascii characters will be encoded into named entities .