Convert a string to the corresponding bit mask.  event - String  Returns a binary number.
160390
function toBitMask(event) {
    if (!_.has(eventMap, event)) {
        throw new Error('Unkown event: ' + event);
    }
    return eventMap[event];
}
569938
def slice_to_percent_mask(slice_value):
  """"""
  if slice_value is None:
    slice_value = slice(None)
  # Select only the elements of the slice
  selected = set(list(range(100))[slice_value])
  # Create the binary mask
  return [i in selected for i in range(100)]
359892
function _substr($binary_string, $start, $length) {
        if (function_exists('mb_substr')) {
            return mb_substr($binary_string, $start, $length, '8bit');
        }
        return substr($binary_string, $start, $length);
    }
301841
function digit(event) {
    var element = event.element
      , code = event.keyCode || event.which
      , result;

    result = (code >= 48 && code <= 57) || code === 8 || code === 46;
    if (!result) event.preventDefault();

    return {
      allowed: result,
      code: code,
      removal: code === 8 || code === 48
    };
  }
950185
def encode(self, value):
        '''
        
        '''
        encoded = strToBytes(value) + b'\x00'
        return Bits(bytes=encoded)
59243
public static int encodeBitString(BitSet value, int nbits, ByteBuffer buf) {
        if (value == null || nbits < value.length()) {
            throw new IllegalArgumentException();
        }

        int pos = buf.position();
        int contentLength = (int) Math.ceil(nbits / 8.0d);
        for (int i = contentLength; i > 0; i--) {
            byte octet = 0;
            for (int j = (i - 1) * 8; j < i * 8; j++) {
                if (value.get(j)) {
                    octet |= BIT_STRING_MASK[j % 8];
                }
            }
            pos--;
            buf.put(pos, octet);
        }

        // Write out padding byte (primitive encoding)
        pos--;
        buf.put(pos, (byte) 0);
        contentLength++;

        buf.position(buf.position() - contentLength);
        int headerLength = DerUtils.encodeIdAndLength(DerId.TagClass.UNIVERSAL, DerId.EncodingType.PRIMITIVE,
                ASN1_BIT_STRING_TAG_NUM, contentLength, buf);
        return headerLength + contentLength;
    }
75704
function isBinaryString( str ) {
	var len,
		ch,
		i;
	if ( !isString( str ) ) {
		return false;
	}
	len = str.length;
	if ( !len ) {
		return false;
	}
	for ( i = 0; i < len; i++ ) {
		ch = str[ i ];
		if ( ch !== '1' && ch !== '0' ) {
			return false;
		}
	}
	return true;
}
986980
def from_str(string):
        
        match = re.match(r'^FINISH READING (\w+)$', string)
        if match:
            return SetFinishedEvent(match.group(1))
        else:
            raise EventParseError
249447
def OnChar(self, event):
        """"""

        key = event.GetKeyCode()

        if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255 or \
           chr(key) in string.digits:
            event.Skip()
1069779
function maskString(srcStr, mask, start, length) {
      var str = String(srcStr), ptn = /[^\u4e00-\u9fa5]/mg, ptn_ = /[\u4e00-\u9fa5]/mg;
      if (isNum(mask)) {
        length = start, start = mask, mask = '*';
      } else if (!isStr(mask)) {
        mask = '*';
      }
      var maskStr = str.substr(start, length).replace(ptn, mask).replace(ptn_, mask + mask);
      return str.substr(0, start) + maskStr + (isUdf(length) ? '' : str.substr(start + length));
    }
441961
function (arr) {
    var out = "", i;
    for (i=0; i<arr.length; i++) {
      out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
    }
    return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
  }
1289276
def _convert_netmask(mask):
    """"""
    if mask not in range(0, 33):
        raise scci.SCCIInvalidInputError(
            'Netmask value is invalid.')

    return socket.inet_ntoa(struct.pack(
        '!L', int('1' * mask + '0' * (32 - mask), 2)))
1372171
function binl2rstr(input) {
        var i, output = '',
          l = input.length * 32;
        for (i = 0; i < l; i += 8) {
          output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
        }
        return output;
      }
1196285
def bfi(value, msb, lsb, field):
    """"""
    mask = bitmask((msb, lsb))
    value &= ~mask
    value |= (field << lsb) & mask
    return value
247696
def bit_mask(name,flags,type=:uint)
      bit_mask = BitMask.new(flags,type)

      typedef(bit_mask,name)
      return bit_mask
    end
934370
def mask(mask_key, data):
        
        if data is None:
            data = ""

        if isinstance(mask_key, six.text_type):
            mask_key = six.b(mask_key)

        if isinstance(data, six.text_type):
            data = six.b(data)

        if numpy:
            origlen = len(data)
            _mask_key = mask_key[3] << 24 | mask_key[2] << 16 | mask_key[1] << 8 | mask_key[0]

            # We need data to be a multiple of four...
            data += bytes(" " * (4 - (len(data) % 4)), "us-ascii")
            a = numpy.frombuffer(data, dtype="uint32")
            masked = numpy.bitwise_xor(a, [_mask_key]).astype("uint32")
            if len(data) > origlen:
              return masked.tobytes()[:origlen]
            return masked.tobytes()
        else:
            _m = array.array("B", mask_key)
            _d = array.array("B", data)
            return _mask(_m, _d)
781969
def event_text_key(self, event):
        
        char = event.char
        if not char or char not in string.ascii_letters:
            # ignore all non letter inputs
            return

        converted_char = invert_shift(char)
        log.debug("convert keycode %s - char %s to %s", event.keycode, repr(char), converted_char)
#         self.text.delete(Tkinter.INSERT + "-1c") # Delete last input char
        self.text.insert(tkinter.INSERT, converted_char) # Insert converted char
        return "break"