/*

Convert the supplied XA return code into its String notation.
506732
public static String convertXACode(int xaRC)
    {
        switch (xaRC)
        {
            // XAER Codes. Most frequently used order.
            case XAException.XAER_NOTA:
                // The XID is not valid. This may mean that the RM has unilaterally rollbacked the Tx.
                return "XAER_NOTA";

            case XAException.XAER_PROTO:
                // Routine invoked in an improper context. i.e. not in the correct order
                return "XAER_PROTO";

            case XAException.XAER_RMERR:
                // An unspecified resource manager error occurred in the transaction branch
                return "XAER_RMERR";

            case XAException.XAER_RMFAIL:
                // The Resource Manager is unavailable
                return "XAER_RMFAIL";

            case XAException.XAER_ASYNC:
                // An Asynchronous operation is already outstanding
                return "XAER_ASYNC";

            case XAException.XAER_DUPID:
                // The XID already exists
                return "XAER_DUPID";

            case XAException.XAER_INVAL:
                // Invalid arguments were given to the call
                return "XAER_INVAL";

            case XAException.XAER_OUTSIDE:
                // Resource manager doing work outside
                return "XAER_OUTSIDE";


            // XA Rollback Codes.
            case XAException.XA_RBROLLBACK:
                // The rollback was caused by an unspecified reason
                return "XA_RBROLLBACK";

            case XAException.XA_RBCOMMFAIL:
                // The rollback was caused by a communication failure
                return "XA_RBCOMMFAIL";

            case XAException.XA_RBDEADLOCK:
                // The rollback was caused by a deadlock
                return "XA_RBDEADLOCK";

            case XAException.XA_RBINTEGRITY:
                // The rollback was caused by a condition that violates the integrity of the resources
                return "XA_RBINTEGRITY";

            case XAException.XA_RBOTHER:
                // The rollback was caused for a reason not described by any other XA_RB* code
                return "XA_RBOTHER";

            case XAException.XA_RBPROTO:
                // The rollback was caused by a protocol error in the resource manager
                return "XA_RBPROTO";

            case XAException.XA_RBTIMEOUT:
                // The rollback was caused by the transaction branch taking too long and it timed out
                return "XA_RBTIMEOUT";

            case XAException.XA_RBTRANSIENT:
                // The rollback was caused by a temporary problem, the transaction branch operation maybe retried.
                return "XA_RBTRANSIENT";


            // XA Codes.
            case XAException.XA_HEURHAZ:
                // The transaction branch may have been heuristically completed
                return "XA_HEURHAZ";

            case XAException.XA_HEURCOM:
                // The transaction branch has been heuristically committed
                return "XA_HEURCOM";

            case XAException.XA_HEURRB:
                // The transaction branch has been heuristically rolled back
                return "XA_HEURRB";

            case XAException.XA_HEURMIX:
                // The transaction branch has been heuristically committed and rolled back
                return "XA_HEURMIX";

            case XAException.XA_NOMIGRATE:
                // Resumption must occur where suspension occurred
                return "XA_NOMIGRATE";

            case XAException.XA_RETRY:
                // Routine returned with no effect and may be re-issued
                return "XA_RETRY";

            case XAException.XA_RDONLY:
                // The transaction branch was read-only and has been committed
                return "XA_RDONLY";

            case XAResource.XA_OK:
                // Normal execution
                return "XA_OK";

            default:
                // Return Code not known
                Integer i = new Integer(xaRC);
                return i.toString();
        }
    }
743636
function decodeString (string) {
	if (string === values.EMPTY) {
		return "";
	} else if (string === values.NULL) {
		return null;
	} else {
		return decodeURIComponent(
			string.replace(/\+/g,"%20"));
	}
}
216840
public static String toStringToken(String pValue) {
        // See if any escaping is needed
        if (pValue.indexOf('\"') < 0 &&
                pValue.indexOf('\\') < 0) {
            return "\"" + pValue + "\"";
        }

        // Escaping is needed
        else {
            StringBuffer buf = new StringBuffer();
            buf.append('\"');
            int len = pValue.length();
            for (int i = 0; i < len; i++) {
                char ch = pValue.charAt(i);
                if (ch == '\\') {
                    buf.append('\\');
                    buf.append('\\');
                } else if (ch == '\"') {
                    buf.append('\\');
                    buf.append('\"');
                } else {
                    buf.append(ch);
                }
            }
            buf.append('\"');
            return buf.toString();
        }
    }
227848
function baseToString(value) {
  // Exit early for strings to avoid a performance hit in some environments.
  if (typeof value == 'string') {
    return value;
  }
  if (isArray_1(value)) {
    // Recursively convert values (susceptible to call stack limits).
    return _arrayMap(value, baseToString) + '';
  }
  if (isSymbol_1(value)) {
    return symbolToString ? symbolToString.call(value) : '';
  }
  var result = (value + '');
  return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
314783
public static String convert( long x, int n, String d ) {
        if (x == 0) {
            return "0";
        }

        String r = "";
        int m = 1 << n;
        m--;
        while( x != 0 ) {
            r = d.charAt((int) (x & m)) + r;
            x = x >>> n;
        }
        return r;
    }
557177
private static String _escapeXML(String value) {
        int len = value.length();
        if (0 == len) {
            return value;
        }
        StringBuilder buf = null;
        for (int i = 0; i < len; i++) {
            char ch = value.charAt(i);
            switch (ch) {
                case '<':
                    if (buf == null) {
                        buf = new StringBuilder(len * 2);
                        if (i > 0) {
                            buf.append(value.substring(0, i));
                        }
                    }
                    buf.append("&lt;");
                    break;
                case '>':
                    if (buf == null) {
                        buf = new StringBuilder(len * 2);
                        if (i > 0) {
                            buf.append(value.substring(0, i));
                        }
                    }
                    buf.append("&gt;");
                    break;
                case '\"':
                    if (buf == null) {
                        buf = new StringBuilder(len * 2);
                        if (i > 0) {
                            buf.append(value.substring(0, i));
                        }
                    }
                    buf.append("&quot;");
                    break;
                case '\'':
                    if (buf == null) {
                        buf = new StringBuilder(len * 2);
                        if (i > 0) {
                            buf.append(value.substring(0, i));
                        }
                    }
                    buf.append("&apos;");
                    break;
                case '&':
                    if (buf == null) {
                        buf = new StringBuilder(len * 2);
                        if (i > 0) {
                            buf.append(value.substring(0, i));
                        }
                    }
                    buf.append("&amp;");
                    break;
                default:
                    if (buf != null) {
                        buf.append(ch);
                    }
                    break;
            }
        }
        if (buf != null) {
            return buf.toString();
        }
        return value;
    }
699751
function codePointAt(str, index) {
  var code = str.charCodeAt(index);
  var low;
  if (0xd800 <= code && code <= 0xdbff) { // High surrogate
    low = str.charCodeAt(index + 1);
    if (!isNaN(low)) {
      code = 0x10000 + (code - 0xd800) * 0x400 + (low - 0xdc00);
    }
  }
  return code;
}
444650
def to_string(x):
    
    if isinstance(x, bytes):
        return x.decode('utf-8')
    if isinstance(x, basestring):
        return x
369639
function toAlpha2(code) {
  if (typeof code === "string") {
    if (/^[0-9]*$/.test(code)) {
      return numericToAlpha2(code);
    }
    if (code.length === 2) {
      return code.toUpperCase();
    }
    if(code.length === 3) {
      return alpha3ToAlpha2(code.toUpperCase());
    }
  }
  if (typeof code === "number") {
    return numericToAlpha2(code);
  }
  return undefined;
}
491673
function toConjoiningJamo(string) {
  if (!hasCompatibilityOrSyllable(string)) {
    return string;
  }

  const result = [];
  for (let i = 0; i < string.length; i++) {
    const charStr = string.charAt(i);
    const codeUnit = charStr.charCodeAt(0);
    result.push(
      (CBASE <= codeUnit && codeUnit < CTOP) ? fromCompatibility(codeUnit) :
      (SBASE <= codeUnit && codeUnit < STOP) ? decomposeSyllable(codeUnit) :
      charStr);
  }
  return result.join('');
}
982028
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xb7', '')
		string = string.replace(u'\u0331', '')
		string = string.replace(u'\u0323', '')
		string = string.strip(' \n\rI.')
		return string
594952
private static String xSystemToUnicode(String s) {
    String result = "";
    int length = s.length();

    for (int i = 0; i < length; i++){
      char c1 = s.charAt(i);
      char c2 = (i + 1 < length) ? s.charAt(i + 1) : ' ';

      if (c2 == 'x') {

        switch (c1) {
          case 'c': result += 'ĉ'; ++i; break;
          case 'g': result += 'ĝ'; ++i; break;
          case 'h': result += 'ĥ'; ++i; break;
          case 'j': result += 'ĵ'; ++i; break;
          case 's': result += 'ŝ'; ++i; break;
          case 'u': result += 'ŭ'; ++i; break;

          default: result += c1; break;
        }
      } else {
        result += c1;
      }
    }
    return result;
  }
301042
function _replaceRegExp(val) {
  const operatorRegex = /(::?|\[)/g;
  const newVal = (val.match(operatorRegex)) ? val.substring(0, val.search(operatorRegex)) : val;
  return _matchRegExp(newVal);
}
1097646
function format(string) {
  string = _.toString(string);

  // Replace all code snippets with a token.
  var snippets = [];
  string = string.replace(reCode, function(match) {
    snippets.push(match);
    return token;
  });

  return string
    // Add line breaks.
    .replace(/:\n(?=[\t ]*\S)/g, ':<br>\n')
    .replace(/\n( *)[-*](?=[\t ]+\S)/g, '\n<br>\n$1*')
    .replace(/^[\t ]*\n/gm, '<br>\n<br>\n')
    // Normalize whitespace.
    .replace(/\n +/g, ' ')
    // Italicize parentheses.
    .replace(/(^|\s)(\(.+\))/g, '$1*$2*')
    // Mark numbers as inline code.
    .replace(/[\t ](-?\d+(?:.\d+)?)(?!\.[^\n])/g, ' `$1`')
    // Replace all tokens with code snippets.
    .replace(reToken, function(match) {
      return snippets.shift();
    })
    .trim();
}
396577
protected static String formatMDLInt(int x, int n) {
        char[] buf = new char[n];
        Arrays.fill(buf, ' ');
        String val = Integer.toString(x);
        if (val.length() > n)
            val = "0";
        int off = n - val.length();
        for (int i = 0; i < val.length(); i++)
            buf[off+i] = val.charAt(i);
        return new String(buf);
    }
1264571
function charCode(chr) {
        var esc = /^\\[xu](.+)/.exec(chr);
        return esc ?
            dec(esc[1]) :
            chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0);
    }
105485
void toStringRep(String indent, XAppender out) {
        out.append(indent).append("<");
        out.append(name);
        if (attributes.size() > 0) {
            for (String an : attributes.keySet()) {
                out.append(" ").append(an).append("='").append(sanitize(attributes.get(an))).append("'");
            }
        }

        if (children.size() == 0) {
            if (content == null) {
                out.append("/>");
            } else {
                out.append(">");
                out.append(sanitize(content));
                out.append("</");
                out.append(name);
                out.append(">");
            }
        } else {
            if (content == null) {
                out.append(String.format(">%n"));
            } else {
                out.append(">");
                out.append(sanitize(content));
                out.append(String.format("%n"));
            }
            for (XElement e : children) {
                e.toStringRep(indent + "  ", out);
            }
            out.append(indent).append("</");
            out.append(name);
            out.append(">");
        }
        out.append(String.format("%n"));
    }