from Semafox.Encoding
543867
function makeEncoding($height = 0, $width = 0, $data = 0, $fw = 0, $bytes = 0, $datablocks = 0, $rsblocks = 0) {
        $t = array(
            'height' => $height,
            'width' => $width,
            'data' => $data,
            'fw' => $fw,
            'bytes' => $bytes,
            'datablocks' => $datablocks,
            'rsblocks' => $rsblocks
        );
        return $t;
    }
1045001
def visitCodeDecl(self, ctx: ShExDocParser.CodeDeclContext):
        
        semact = SemAct()
        semact.name = self.context.iri_to_iriref(ctx.iri())
        if ctx.CODE():
            semact.code = ctx.CODE().getText()[1:-2].replace('\\%', '%').encode('utf-8').decode('unicode-escape')
        self.semacts.append(semact)
614292
function amf0encUString(s) {
    var data = new Buffer(s,'utf8');
    var sLen = new Buffer(2);
    sLen.writeUInt16BE(data.length,0);
    return Buffer.concat([sLen,data]);
}
584033
def _get_encoding():
    """"""

    encoding = sys.getfilesystemencoding()
    if encoding is None:
        if is_darwin:
            encoding = "utf-8"
        elif is_win:
            encoding = "mbcs"
        else:
            encoding = "ascii"
    encoding = _normalize_codec(encoding)
    return encoding
1088105
def get_encodings_from_content(content):
    

    charset_re = re.compile(r'<meta.*?charset=["\']*(.+?)["\'>]', flags=re.I)
    pragma_re = re.compile(r'<meta.*?content=["\']*;?charset=(.+?)["\'>]', flags=re.I)
    xml_re = re.compile(r'^<\?xml.*?encoding=["\']*(.+?)["\'>]')

    return (charset_re.findall(content) +
            pragma_re.findall(content) +
            xml_re.findall(content))
496827
def content_encoding
      if content_type = headers["content-type"]
        mime_type, charset = content_type.split(SEMICOLON, 2)
        charset = charset[CHARSET_OFFSET] if charset
        charset ||= EMPTY

        if charset.empty? and mime_type.start_with?("text/")
          Encoding::UTF_8
        elsif charset.empty?
          Encoding::BINARY
        else
          ENCODINGS[charset] or raise StompParser::InvalidEncodingError, "invalid encoding #{charset.inspect}"
        end
      else
        Encoding::BINARY
      end
    end
637249
def _encode_string(s):
        
        if six.PY2 and isinstance(s, unicode):
            return s.encode('utf-8')
        return s
949510
def get_encoding_from_headers(headers):
    

    content_type = headers.get('content-type')

    if not content_type:
        return None

    content_type, params = _parse_content_type_header(content_type)

    if 'charset' in params:
        return params['charset'].strip("'\"")

    if 'text' in content_type:
        return 'ISO-8859-1'
1040520
public static void decodeUtf8To(String query, int offset, int length, MultiMap<String> map) {
        Utf8StringBuilder buffer = new Utf8StringBuilder();
        synchronized (map) {
            String key = null;
            String value = null;

            int end = offset + length;
            for (int i = offset; i < end; i++) {
                char c = query.charAt(i);
                switch (c) {
                    case '&':
                        value = buffer.toReplacedString();
                        buffer.reset();
                        if (key != null) {
                            map.add(key, value);
                        } else if (value != null && value.length() > 0) {
                            map.add(value, "");
                        }
                        key = null;
                        value = null;
                        break;

                    case '=':
                        if (key != null) {
                            buffer.append(c);
                            break;
                        }
                        key = buffer.toReplacedString();
                        buffer.reset();
                        break;

                    case '+':
                        buffer.append((byte) ' ');
                        break;

                    case '%':
                        if (i + 2 < end) {
                            char hi = query.charAt(++i);
                            char lo = query.charAt(++i);
                            buffer.append(decodeHexByte(hi, lo));
                        } else {
                            throw new Utf8Appendable.NotUtf8Exception("Incomplete % encoding");
                        }
                        break;

                    default:
                        buffer.append(c);
                        break;
                }
            }

            if (key != null) {
                value = buffer.toReplacedString();
                buffer.reset();
                map.add(key, value);
            } else if (buffer.length() > 0) {
                map.add(buffer.toReplacedString(), "");
            }
        }
    }
814768
def read_utf8(fh, byteorder, dtype, count, offsetsize):
    """"""
    return fh.read(count).decode('utf-8')
1015261
def _get_codepage_char_map(self, encoding):
        
        # Skip things that were loaded previously
        if encoding in self.available_characters:
            return self.available_characters[encoding]
        codepage_char_list = self._get_codepage_char_list(encoding)
        codepage_char_map = dict((utf8, i + 128) for (i, utf8) in enumerate(codepage_char_list))
        self.available_characters[encoding] = codepage_char_map
        return codepage_char_map
717694
def _ensure_decoded(s):
    
    if isinstance(s, np.bytes_):
        s = s.decode('UTF-8')
    return s
300497
def detect_encoding(value):
    """"""
    # https://tools.ietf.org/html/rfc4627#section-3
    if six.PY2:
        null_pattern = tuple(bool(ord(char)) for char in value[:4])
    else:
        null_pattern = tuple(bool(char) for char in value[:4])

    encodings = {
        # Zero is a null-byte, 1 is anything else.
        (0, 0, 0, 1): 'utf-32-be',
        (0, 1, 0, 1): 'utf-16-be',
        (1, 0, 0, 0): 'utf-32-le',
        (1, 0, 1, 0): 'utf-16-le',
    }

    return encodings.get(null_pattern, 'utf-8')
690766
def encoding(encoding=True):
    """"""
    if isinstance(encoding, str):
        encoding = True

    def dec(f):
        f._nvim_decode = encoding
        return f
    return dec
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)
287327
function utf8ByteLength(str) {
  let s = str.length;
  let i;
  for (i = str.length - 1; i >= 0; i -= 1) {
    const code = str.charCodeAt(i);
    if (code > 0x7f && code <= 0x7ff) {
      s += 1;
    } else if (code > 0x7ff && code <= 0xffff) {
      s += 2;
    }

    // trail surrogate
    if (code >= 0xDC00 && code <= 0xDFFF) {
      i -= 1;
    }
  }

  return s;
}
89986
function( /*String*/ path, /*String?*/ encoding) {
					path = frontSlash(path);
					if (encoding === 'utf-8') {
						encoding = 'utf8';
					}
					if (!encoding) {
						encoding = 'utf8';
					}

					var text = cache[path].contents + "";
					//Hmm, would not expect to get A BOM, but it seems to happen,
					//remove it just in case.
					if (text.indexOf('\uFEFF') === 0) {
						text = text.substring(1, text.length);
					}


					return text;
				}