src/compile/references.js
function convert(str) {

    if (typeof str !== 'string') return str;

    var result = ""
    var escape = false
    var i, c, cstr;

    for (i = 0 ; i < str.length ; i++) {
      c = str.charAt(i);
      if ((' ' <= c && c <= '~') || (c === '\r') || (c === '\n')) {
        if (c === '&') {
          cstr = "&amp;"
          escape = true
        } else if (c === '<') {
          cstr = "&lt;"
          escape = true
        } else if (c === '>') {
          cstr = "&gt;"
          escape = true
        } else {
          cstr = c.toString()
        }
      } else {
        cstr = "&#" + c.charCodeAt().toString() + ";"
      }

      result = result + cstr
    }

    return escape ? result : str
  }
function convert(str) {

    if (typeof str !== 'string') return str;

    var result = ""
    var escape = false
    var i, c, cstr;

    for (i = 0 ; i < str.length ; i++) {
      c = str.charAt(i);
      if ((' ' <= c && c <= '~') || (c === '\r') || (c === '\n')) {
        if (c === '&') {
          cstr = "&amp;"
          escape = true
        } else if (c === '<') {
          cstr = "&lt;"
          escape = true
        } else if (c === '>') {
          cstr = "&gt;"
          escape = true
        } else {
          cstr = c.toString()
        }
      } else {
        cstr = "&#" + c.charCodeAt().toString() + ";"
      }

      result = result + cstr
    }

    return escape ? result : str
  }
function convert ( str ) { if ( typeof str !== 'string' ) return str ; var result = "" var escape = false var i , c , cstr ; for ( i = 0 ; i < str . length ; i ++ ) { c = str . charAt ( i ) ; if ( ( ' ' <= c && c <= '~' ) || ( c === '\r' ) || ( c === '\n' ) ) { if ( c === '&' ) { cstr = "&amp;" escape = true } else if ( c === '<' ) { cstr = "&lt;" escape = true } else if ( c === '>' ) { cstr = "&gt;" escape = true } else { cstr = c . toString ( ) } } else { cstr = "&#" + c . charCodeAt ( ) . toString ( ) + ";" } result = result + cstr } return escape ? result : str }
unicode转码
unicode转码