Alias for mb_regex_encoding which default to a noop if the mbstring
module is not installed.
334087
protected function regexEncoding()
	{
		trigger_error('Function ' . __METHOD__ . ' not implemented yet');

		static $functionExists;

		if ($functionExists === null) {
			$functionExists = function_exists('\mb_regex_encoding');
		}

		if ($functionExists) {
			$args = func_get_args();
			return call_user_func_array('\mb_regex_encoding', $args);
		}
	}
1114361
protected function regexEncoding()
    {
        static $functionExists;

        if ($functionExists === null) {
            $functionExists = function_exists('\mb_regex_encoding');
        }

        if ($functionExists) {
            $args = func_get_args();
            return call_user_func_array('\mb_regex_encoding', $args);
        }
    }
226040
def _detect_encoding(self, source_file):
        """"""

        encoding = self._guess(source_file)
        # If we didn't explicitly detect an encoding, assume default.
        if encoding is None:
            encoding = self.default_encoding

        return encoding
19849
def ensure_str(text):
    """
    if isinstance(text, unicode):
        try:
            return text.encode(pyreadline_codepage, u"replace")
        except (LookupError, TypeError):
            return text.encode(u"ascii", u"replace")
    return text
866572
def ensure_binary_encoding(string)
      raise ArgumentError, "String is missing" if !string
      if string.encoding == Encoding::BINARY
        string
      else
        string.b
      end
    end
1195955
def _check_for_encoding(b):
    """"""
    eol = b.find(b'\n')
    if eol < 0:
        return _check_line_for_encoding(b)[0]
    enc, again = _check_line_for_encoding(b[:eol])
    if enc or not again:
        return enc
    eol2 = b.find(b'\n', eol + 1)
    if eol2 < 0:
        return _check_line_for_encoding(b[eol + 1:])[0]
    return _check_line_for_encoding(b[eol + 1:eol2])[0]
422625
def _detect_buffer_encoding(self, f):
        """"""

        encoding = None
        with contextlib.closing(mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)) as m:
            encoding = self._analyze_file(m)
        return encoding
1330937
def _build_abbreviation_regex(input_string):
        
        result=''
        for char in input_string:
            result += '[%s%s]?' % (char.upper(), char.lower())
        return '(%s)' % result
372449
def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
    
    # Handle the common case first for performance reasons.
    if isinstance(s, bytes):
        if encoding == 'utf-8':
            return s
        else:
            return s.decode('utf-8', errors).encode(encoding, errors)
    if strings_only and is_protected_type(s):
        return s
    if isinstance(s, memoryview):
        return bytes(s)
    if not isinstance(s, str):
        return str(s).encode(encoding, errors)
    else:
        return s.encode(encoding, errors)
822622
def detect_encoding(data, encoding=None, fallback='latin1', is_html=False):
    '''
    '''
    if encoding:
        encoding = normalize_codec_name(encoding)

    bs4_detector = EncodingDetector(
        data,
        override_encodings=(encoding,) if encoding else (),
        is_html=is_html
    )
    candidates = itertools.chain(bs4_detector.encodings, (fallback,))

    for candidate in candidates:
        if not candidate:
            continue

        candidate = normalize_codec_name(candidate)

        if not candidate:
            continue

        if candidate == 'ascii' and fallback != 'ascii':
            # it's never ascii :)
            # Falling back on UTF-8/CP-1252/Latin-1 reduces chance of
            # failure
            continue

        if try_decoding(data, candidate):
            return candidate

    raise ValueError('Unable to detect encoding.')
537018
def choose_encoding(cls, parent, path, encoding):
        
        dlg = cls(parent, path, encoding)
        dlg.exec_()
        return dlg.ui.comboBoxEncodings.current_encoding
392636
def detectEncodingMeta(self):
        
        buffer = self.rawStream.read(self.numBytesMeta)
        assert isinstance(buffer, bytes)
        parser = EncodingParser(buffer)
        self.rawStream.seek(0)
        encoding = parser.getEncoding()

        if encoding is not None and encoding.name in ("utf-16be", "utf-16le"):
            encoding = lookupEncoding("utf-8")

        return encoding
1360263
def _regex_to_static(src, regex):
    '''
    
    '''
    if not src or not regex:
        return None

    try:
        compiled = re.compile(regex, re.DOTALL)
        src = [line for line in src if compiled.search(line) or line.count(regex)]
    except Exception as ex:
        raise CommandExecutionError("{0}: '{1}'".format(_get_error_message(ex), regex))

    return src and src or []
644408
def __getfilesystemencoding():
    '''
    
    '''
    try:
        ret = sys.getfilesystemencoding()
        if not ret:
            raise RuntimeError('Unable to get encoding.')
        return ret
    except:
        try:
            #Handle Jython
            from java.lang import System  # @UnresolvedImport
            env = System.getProperty("os.name").lower()
            if env.find('win') != -1:
                return 'ISO-8859-1'  #mbcs does not work on Jython, so, use a (hopefully) suitable replacement
            return 'utf-8'
        except:
            pass

        #Only available from 2.3 onwards.
        if sys.platform == 'win32':
            return 'mbcs'
        return 'utf-8'
1249845
function b64utob64(s) {
    if (s.length % 4 == 2) s = s + "==";
    else if (s.length % 4 == 3) s = s + "=";
    s = s.replace(/-/g, "+");
    s = s.replace(/_/g, "/");
    return s;
}
238991
def detect_model_name(string):
    
    match = re.match(MODEL_NAME_REGEX, string)
    if match:
        return match.group()
    return None
717694
def _ensure_decoded(s):
    
    if isinstance(s, np.bytes_):
        s = s.decode('UTF-8')
    return s