Convert an ISO 3166-1 alpha-3 code to alpha-2

@param  {String} alpha3 USA
@return {String}
13063
function to2 (alpha3) {
    if (alpha3 && alpha3.length > 1) state = alpha3
    if (state.length !== 3) return state
    return ISOCodes.filter(function (row) {
      return row.alpha3 === state
    })[0].alpha2
  }
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;
}
644967
def int_to_alpha(n, upper=True):
    ""
    casenum = 65 if upper else 97
    label = ''
    count= 0
    if n == 0: return str(chr(n + casenum))
    while n >= 0:
        mod, div = n % 26, n
        for _ in range(count):
            div //= 26
        div %= 26
        if count == 0:
            val = mod
        else:
            val = div
        label += str(chr(val + casenum))
        count += 1
        n -= 26**count
    return label[::-1]
1065884
function (cell) {
      var num = cell.match(/\d+$/),
          alpha = cell.replace(num, '');

      return {
        alpha: alpha,
        num: parseInt(num[0], 10)
      }
    }
1101539
function convertColorToString(color) {
  const {type, values} = color

  // Only convert the first 3 values to int (i.e. not alpha)
  if (type.indexOf('rgb') > -1)
    for (let i = 0; i < 3; i++) values[i] = parseInt(values[i])

  let colorString

  if (type.indexOf('hsl') > -1)
    colorString = `${color.type}(${values[0]}, ${values[1]}%, ${values[2]}%`
  else colorString = `${color.type}(${values[0]}, ${values[1]}, ${values[2]}`

  if (values.length === 4) colorString += `, ${color.values[3].toFixed(2)})`
  else colorString += ')'

  return colorString
}
803626
static String getJavaScriptUnicodeEscapeString(char ch) {
		int chInt = (int)ch;
		if(chInt>=ENCODE_RANGE_1_START && chInt<ENCODE_RANGE_1_END) {
			return javaScriptUnicodeEscapeStrings1[chInt - ENCODE_RANGE_1_START];
		}
		if(chInt>=ENCODE_RANGE_2_START && chInt<ENCODE_RANGE_2_END) {
			return javaScriptUnicodeEscapeStrings2[chInt - ENCODE_RANGE_2_START];
		}
		if(chInt>=ENCODE_RANGE_3_START && chInt<ENCODE_RANGE_3_END) {
			return javaScriptUnicodeEscapeStrings3[chInt - ENCODE_RANGE_3_START];
		}
		// No encoding needed
		return null;
	}
874837
def alpha_cased(text, lower=False):
    
    text = "".join(filter(
            lambda c: c.isalpha() or c == GENERIC_PROTOCOL_KEY, text))
    return text.lower() if lower else text.upper()
462411
public static function alphaNumChars()
    {
        return self::oneOf(
            self::choose(48, 57),
            self::choose(65, 90),
            self::choose(97, 122)
        )->fmap('chr');
    }
920452
function convertCodePoints(regexp) {
		return regexp.replace(/\\x\{([0-9a-fA-F]+)\}/g, function(m, chars) {
			// pad to four hex digits
			while (chars.length < 4) {
				chars = '0' + chars;
			}
			return '\\u' + chars;
		});
	}
303747
function toAscii(hex) {
  var str = ''; // eslint-disable-line
  var i = 0, l = hex.length; // eslint-disable-line

  if (hex.substring(0, 2) === '0x') {
    i = 2;
  }

  for (; i < l; i += 2) {
    const code = parseInt(hex.substr(i, 2), 16);
    str += String.fromCharCode(code);
  }

  return str;
}
49908
function getCode(code, opts, attrs, url) {
  var type = getType(attrs),
    parserOpts = getParserOptions(attrs)

  //#if NODE
  // istanbul ignore else
  if (url) {
    var src = getAttr(attrs, 'src')
    if (src) {
      var
        charset = getAttr(attrs, 'charset'),
        file = path.resolve(path.dirname(url), src)
      code = require('fs').readFileSync(file, charset || 'utf8')
    }
  }
  //#endif
  return _compileJS(code, opts, type, parserOpts, url)
}
301782
function convertCodeUnitToBytes(code_unit, utf16be) {
    // 1. Let byte1 be code unit >> 8.
    var byte1 = code_unit >> 8;

    // 2. Let byte2 be code unit & 0x00FF.
    var byte2 = code_unit & 0x00FF;

    // 3. Then return the bytes in order:
        // utf-16be flag is set: byte1, then byte2.
    if (utf16be)
      return [byte1, byte2];
    // utf-16be flag is unset: byte2, then byte1.
    return [byte2, byte1];
  }
859548
function convertCode2Script(code) {
    // clean source code comment
    return code
        .replace(/\/\/\/ <reference path="[\s\S]*?>/gm, '')
        .replace(/\r\n/gm, '\n')
        .replace(convert.mapFileCommentRegex, '')
        .trim('\n') + '\n';
}
701194
function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
	}
1344216
function unescape(str) {

    return str.replace(constants.REGEX.unescape, (match, hex1, hex2, hex3, octal, special) => {

        let hex = hex1 !== undefined ? hex1 : hex2 !== undefined ? hex2 : hex3 !== undefined ? hex3 : undefined;

        if (hex !== undefined) {
            return String.fromCodePoint(parseInt(hex, 16));

        } else if (octal !== undefined) {
            return String.fromCodePoint(parseInt(octal, 8));

        } else {
            return constants.SPECIAL_CHARS[special];
        }

    });

}
625106
function _convertUnicode(originalStr) {
  let m;
  let c;
  let cStr;
  let lastI = 0;

  // Matches \u#### but not \\u####
  const unicodeRegex = /\\u[0-9a-fA-F]{4}/g;

  let convertedStr = '';
  while ((m = unicodeRegex.exec(originalStr))) {
    // Don't convert if the backslash itself is escaped
    if (originalStr[m.index - 1] === '\\') {
      continue;
    }

    try {
      cStr = m[0].slice(2); // Trim off start
      c = String.fromCharCode(parseInt(cStr, 16));
      if (c === '"') {
        // Escape it if it's double quotes
        c = `\\${c}`;
      }

      // + 1 to account for first matched (non-backslash) character
      convertedStr += originalStr.slice(lastI, m.index) + c;
      lastI = m.index + m[0].length;
    } catch (err) {
      // Some reason we couldn't convert a char. Should never actually happen
      console.warn('Failed to convert unicode char', m[0], err);
    }
  }

  // Finally, add the rest of the string to the end.
  convertedStr += originalStr.slice(lastI, originalStr.length);

  return convertedStr;
}
175905
public function convertAlpha2ToAlpha3($alpha2)
    {
        if (!isset(self::$codes[$alpha2])) {
            return null;
        }

        return self::$codes[$alpha2];
    }