Takes marc 048ab instrument code, and translates it to human-displayable
 string. Takes first two chars of 048a or b, to translate (ignores numeric code)

 Pass in custom spec if you want just a or b, to separate soloists or whatever.
188717
def marc_instrumentation_humanized(spec = "048ab", options = {})
      translation_map = Traject::TranslationMap.new(options[:translation_map] || "marc_instruments")

      extractor = MarcExtractor.new(spec, :separator => nil)

      lambda do |record, accumulator|
        values = extractor.extract(record)
        human = values.collect do |value|
          translation_map[ value.slice(0, 2) ]
        end.uniq
        accumulator.concat human if human && human.length > 0
      end
    end
399721
function str2ab(stringToEncode, insertBom) {
      stringToEncode = stringToEncode.replace(/\r\n/g,"\n");

      var utftext = []
        , n
        , c
        ;

      if (true === insertBom)  {
        utftext[0] =  0xef;
        utftext[1] =  0xbb;
        utftext[2] =  0xbf;
      }

      for (n = 0; n < stringToEncode.length; n += 1) {

        c = stringToEncode.charCodeAt(n);

        if (c < 128) {
            utftext[utftext.length]= c;
        }
        else if((c > 127) && (c < 2048)) {
            utftext[utftext.length] = (c >> 6) | 192;
            utftext[utftext.length] = (c & 63) | 128;
        }
        else {
            utftext[utftext.length] = (c >> 12) | 224;
            utftext[utftext.length] = ((c >> 6) & 63) | 128;
            utftext[utftext.length] = (c & 63) | 128;
        }

      }
      return new Uint8Array(utftext).buffer;
    }
789531
def example(self) -> str:
        
        if self.rgb_mode:
            colorcode = '\033[38;2;{};{};{}m'.format(*self.rgb)
        else:
            colorcode = '\033[38;5;{}m'.format(self.code)
        return '{code}{s}\033[0m'.format(code=colorcode, s=self)
813924
def translate_escaped_str(cls, str_val):
        """"""
        if isinstance(str_val, string_types):
            str_val = str_val.encode('unicode_escape')
            if sys.version_info >= (3, 0):
                str_val = str_val.decode('utf-8')
            str_val = str_val.replace('"', r'\"')
        return '"{}"'.format(str_val)
755643
public function toHemholtz() {
        $str = $this->step;
        if ($this->octave < 3) {
            $str = strtoupper($str);
        } else {
            $str = strtolower($str);
        }

        switch ($this->alter) {
            case -2:
                $str .= 'bb';
                break;
            case -1:
                $str .= 'b';
                break;
            case 1:
                $str .= '#';
                break;
            case 2:
                $str .= '##';
                break;
            default:
                // nothing
        }
        if ($this->octave > 3) {
            $str .= str_repeat("'", $this->octave - 3);
        }
        if ($this->octave < 2) {
            $str .= str_repeat(",", ($this->octave * -1) + 2);
        }
        return $str;
    }
1255064
def UTF8ToUTF16BE(instr, setbom=True):
    ""
    outstr = "".encode()
    if (setbom):
        outstr += "\xFE\xFF".encode("latin1")
    if not isinstance(instr, unicode):
        instr = instr.decode('UTF-8')
    outstr += instr.encode('UTF-16BE')
    # convert bytes back to fake unicode string until PEP461-like is implemented
    if PY3K:
        outstr = outstr.decode("latin1")
    return outstr
1037496
def translate_basic(usercode):
    
    codenum = get_code_num(codes['fore'][usercode])
    colorcode = codeformat(codenum)
    msg = 'Name: {:>10}, Number: {:>3}, EscapeCode: {!r}'.format(
        usercode,
        codenum,
        colorcode
    )
    if disabled():
        return msg
    return str(C(msg, fore=usercode))
254417
function _charToUtf8(&$char)
	{
		$c = (int)$this->ascMap[$this->charset][$char];
		if ($c < 0x80)
			$char = \chr($c);
		else if($c<0x800) /* 2 bytes */
			$char = (\chr(0xC0 | $c>>6) . \chr(0x80 | $c & 0x3F));
		else if($c<0x10000) /* 3 bytes */
			$char = (\chr(0xE0 | $c>>12) . \chr(0x80 | $c>>6 & 0x3F) . \chr(0x80 | $c & 0x3F));
		else if($c<0x200000) /* 4 bytes */
			$char = (\chr(0xF0 | $c>>18) . \chr(0x80 | $c>>12 & 0x3F) . \chr(0x80 | $c>>6 & 0x3F) . \chr(0x80 | $c & 0x3F));
	}
207258
function prepare (iban) {
  // move front to the back
  iban = iban.slice(4) + iban.slice(0, 4)

  // translate letters to numbers
  return iban.split('').map(function (n) {
    var code = n.charCodeAt(0)
    // 65 == A, 90 == Z in ASCII
    if (code >= 65 && code <= 90) {
      // A = 10, B = 11, ... Z = 35
      return code - 65 + 10
    } else {
      return n
    }
  }).join('')
}
236558
function(abbr) {
			abbr = abbr || '';
			
			var that = this;
			
			// find multiplier
			abbr = abbr.replace(/\*(\d+)?$/, function(str, repeatCount) {
				that._setRepeat(repeatCount);
				return '';
			});
			
			this.abbreviation = abbr;
			
			var abbrText = extractText(abbr);
			if (abbrText) {
				abbr = abbrText.element;
				this.content = this._text = abbrText.text;
			}
			
			var abbrAttrs = parseAttributes(abbr);
			if (abbrAttrs) {
				abbr = abbrAttrs.element;
				this._attributes = abbrAttrs.attributes;
			}
			
			this._name = abbr;
			
			// validate name
			if (this._name && !reValidName.test(this._name)) {
				throw new Error('Invalid abbreviation');
			}
		}
303744
def from_string(string):
        
        lines = [line.strip() for line in string.splitlines()]

        comment = lines[0]
        num_kpts = int(lines[1].split()[0].strip())
        style = lines[2].lower()[0]

        # Fully automatic KPOINTS
        if style == "a":
            return Kpoints.automatic(int(lines[3]))

        coord_pattern = re.compile(r'^\s*([\d+.\-Ee]+)\s+([\d+.\-Ee]+)\s+'
                                   r'([\d+.\-Ee]+)')

        # Automatic gamma and Monk KPOINTS, with optional shift
        if style == "g" or style == "m":
            kpts = [int(i) for i in lines[3].split()]
            kpts_shift = (0, 0, 0)
            if len(lines) > 4 and coord_pattern.match(lines[4]):
                try:
                    kpts_shift = [float(i) for i in lines[4].split()]
                except ValueError:
                    pass
            return Kpoints.gamma_automatic(kpts, kpts_shift) if style == "g" \
                else Kpoints.monkhorst_automatic(kpts, kpts_shift)

        # Automatic kpoints with basis
        if num_kpts <= 0:
            style = Kpoints.supported_modes.Cartesian if style in "ck" \
                else Kpoints.supported_modes.Reciprocal
            kpts = [[float(j) for j in lines[i].split()] for i in range(3, 6)]
            kpts_shift = [float(i) for i in lines[6].split()]
            return Kpoints(comment=comment, num_kpts=num_kpts, style=style,
                           kpts=kpts, kpts_shift=kpts_shift)

        # Line-mode KPOINTS, usually used with band structures
        if style == "l":
            coord_type = "Cartesian" if lines[3].lower()[0] in "ck" \
                else "Reciprocal"
            style = Kpoints.supported_modes.Line_mode
            kpts = []
            labels = []
            patt = re.compile(r'([e0-9.\-]+)\s+([e0-9.\-]+)\s+([e0-9.\-]+)'
                              r'\s*!*\s*(.*)')
            for i in range(4, len(lines)):
                line = lines[i]
                m = patt.match(line)
                if m:
                    kpts.append([float(m.group(1)), float(m.group(2)),
                                 float(m.group(3))])
                    labels.append(m.group(4).strip())
            return Kpoints(comment=comment, num_kpts=num_kpts, style=style,
                           kpts=kpts, coord_type=coord_type, labels=labels)

        # Assume explicit KPOINTS if all else fails.
        style = Kpoints.supported_modes.Cartesian if style in "ck" \
            else Kpoints.supported_modes.Reciprocal
        kpts = []
        kpts_weights = []
        labels = []
        tet_number = 0
        tet_weight = 0
        tet_connections = None

        for i in range(3, 3 + num_kpts):
            toks = lines[i].split()
            kpts.append([float(j) for j in toks[0:3]])
            kpts_weights.append(float(toks[3]))
            if len(toks) > 4:
                labels.append(toks[4])
            else:
                labels.append(None)
        try:
            # Deal with tetrahedron method
            if lines[3 + num_kpts].strip().lower()[0] == "t":
                toks = lines[4 + num_kpts].split()
                tet_number = int(toks[0])
                tet_weight = float(toks[1])
                tet_connections = []
                for i in range(5 + num_kpts, 5 + num_kpts + tet_number):
                    toks = lines[i].split()
                    tet_connections.append((int(toks[0]),
                                            [int(toks[j])
                                             for j in range(1, 5)]))
        except IndexError:
            pass

        return Kpoints(comment=comment, num_kpts=num_kpts,
                       style=Kpoints.supported_modes[str(style)],
                       kpts=kpts, kpts_weights=kpts_weights,
                       tet_number=tet_number, tet_weight=tet_weight,
                       tet_connections=tet_connections, labels=labels)
79298
def keysym_to_string(keysym):
    ''''''

    # ISO latin 1, LSB is the code
    if keysym & 0xff00 == 0:
        return chr(keysym & 0xff)

    if keysym in [XK_BackSpace, XK_Tab, XK_Clear, XK_Return,
                  XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete]:
        return chr(keysym & 0xff)

    # We should be able to do these things quite automatically
    # for latin2, latin3, etc, in Python 2.0 using the Unicode,
    # but that will have to wait.

    return None
885294
private static String translateFormat(String formatString, Map<String, String> mapping, String escapeStart, String escapeEnd, String targetEscapeStart, String targetEscapeEnd) {
		int beginIndex = 0;
		int i = 0;
		char lastChar = 0;
		char currentChar = 0;
		String resultString = "";
		char esc1 = escapeStart.charAt(0);
		char esc2 = escapeEnd.charAt(0);

		for (; i < formatString.length(); i++) {
			currentChar = formatString.charAt(i);
			if (i > 0 && lastChar != currentChar) {
				resultString += mapSubformat(formatString, mapping, beginIndex, i, escapeStart, escapeEnd, targetEscapeStart, targetEscapeEnd);
				beginIndex = i;
			}
			lastChar = currentChar;
			if (currentChar == esc1) {
				i++;
				while (i< formatString.length() && formatString.charAt(i) != esc2) {
					i++;
				}
				resultString += targetEscapeStart;
				resultString += formatString.substring(beginIndex+1, i);
				resultString += targetEscapeEnd;
				i++;
				if (i < formatString.length()) {
					lastChar = formatString.charAt(i);
				}
				beginIndex = i;
			}
		}
		
		if (beginIndex < formatString.length() && i <= formatString.length()) {
			return resultString + mapSubformat(formatString, mapping, beginIndex, i, escapeStart, escapeEnd, targetEscapeStart, targetEscapeEnd);
		} else {
			return resultString;
		}

	}
1237394
def wxcode(code: str) -> str:
    
    if not code:
        return ''
    ret = ''
    if code[0] == '+':
        ret = 'Heavy '
        code = code[1:]
    elif code[0] == '-':
        ret = 'Light '
        code = code[1:]
    # Return code if code is not a code, ex R03/03002V03
    if len(code) not in [2, 4, 6]:
        return code
    for _ in range(len(code) // 2):
        if code[:2] in WX_TRANSLATIONS:
            ret += WX_TRANSLATIONS[code[:2]] + ' '
        else:
            ret += code[:2]
        code = code[2:]
    return ret.strip()
1293918
def m_b(mbmb, scale, f, alphasMZ=0.1185, loop=3):
    """
    if scale == mbmb and f == 5:
        return mbmb  # nothing to do
    _sane(scale, f)
    alphas_mb = alpha_s(mbmb, 5, alphasMZ=alphasMZ, loop=loop)
    crd = rundec.CRunDec()
    if f == 5:
        alphas_scale = alpha_s(scale, f, alphasMZ=alphasMZ, loop=loop)
        return crd.mMS2mMS(mbmb, alphas_mb, alphas_scale, f, loop)
    elif f == 4:
        crd.nfMmu.Mth = 4.8
        crd.nfMmu.muth = 4.8
        crd.nfMmu.nf = 5
        return crd.mH2mL(mbmb, alphas_mb, mbmb, crd.nfMmu, scale, loop)
    elif f == 3:
        mc = 1.3
        crd.nfMmu.Mth = 4.8
        crd.nfMmu.muth = 4.8
        crd.nfMmu.nf = 5
        mbmc = crd.mH2mL(mbmb, alphas_mb, mbmb, crd.nfMmu, mc, loop)
        crd.nfMmu.Mth = mc
        crd.nfMmu.muth = mc
        crd.nfMmu.nf = 4
        alphas_mc = alpha_s(mc, 4, alphasMZ=alphasMZ, loop=loop)
        return crd.mH2mL(mbmc, alphas_mc, mc, crd.nfMmu, scale, loop)
    elif f == 6:
        crd.nfMmu.Mth = 170
        crd.nfMmu.muth = 170
        crd.nfMmu.nf = 6
        return crd.mL2mH(mbmb, alphas_mb, mbmb, crd.nfMmu, scale, loop)
    else:
        raise ValueError("Invalid input: f={}, scale={}".format(f, scale))
114210
protected String replaceTransforms(String code)
    {
        if (isVulkanInstance())
            return code.replace("@MATRIX_UNIFORMS", sTransformVkUBOCode);
        if (mUseTransformBuffer)
            return code.replace("@MATRIX_UNIFORMS", sTransformUBOCode);
        return code.replace("@MATRIX_UNIFORMS", sTransformUniformCode);
    }
452466
function str2ab (str) {
  var buf = new ArrayBuffer(str.length * 2) // 2 bytes for each char
  var bufView = new Uint16Array(buf)
  for (var i = 0, strLen = str.length; i < strLen; i++) {
    bufView[i] = str.charCodeAt(i)
  }
  return new Uint8Array(buf)
  /*var idx, len = str.length, arr = new Array( len );
   for ( idx = 0 ; idx < len ; ++idx ) {
       arr[ idx ] = str.charCodeAt(idx) & 0xFF;
   }
   // You may create an ArrayBuffer from a standard array (of values) as follows:
   return new Uint8Array( arr )*/
}