Read the contents of a file.

    :param name: The name of the file in the current directory.
    :param encoding: The encoding of the file; defaults to utf-8.
    :return: The contents of the file.
503496
def _read_file(name, encoding='utf-8'):
    
    with codecs.open(name, encoding=encoding) as f:
        return f.read()
277881
def read_txt_file(fname):
    
    encodings = ['utf-8-sig', 'cp1252']
    with open(fname, 'rb') as f:
        content = bytes(f.read())

    for i in encodings:
        try:
            result = content.decode(i)
            if six.PY2:
                result = result.encode('utf-8')
            return result
        except UnicodeDecodeError:
            pass

    global_.FILENAME = fname
    errmsg.syntax_error(1, 'Invalid file encoding. Use one of: %s' % ', '.join(encodings))
    return ''
586886
def read_file(self, filename):
        
        logger.info("Reading file: %s", format_path(filename))
        contents = self.context.read_file(filename)
        num_lines = len(contents.splitlines())
        logger.debug("Read %s from %s.",
                     pluralize(num_lines, 'line'),
                     format_path(filename))
        return contents.rstrip()
222355
def load_data_file(filename, encoding='utf-8'):
    
    data = pkgutil.get_data(PACKAGE_NAME, os.path.join(DATA_DIR, filename))
    return data.decode(encoding).splitlines()
1303453
def read(self):
        """"""
        lines = self.readlines()
        if self.metadata and 'encoding' in self.metadata:
            encoding = self.metadata['encoding']
        else:
            encoding = 'utf-8'
        if sys.version < '3':
            return "\n".join( unicode(line, 'utf-8') if isinstance(line, str) else line for line in lines)
        else:
            return "\n".join( str(line, 'utf-8') if isinstance(line, bytes) else line for line in lines)
960613
def _read_python_source(self, filename):
        
        try:
            f = open(filename, "rb")
        except IOError as err:
            self.log_error("Can't open %s: %s", filename, err)
            return None, None
        try:
            encoding = tokenize.detect_encoding(f.readline)[0]
        finally:
            f.close()
        with _open_with_encoding(filename, "r", encoding=encoding) as f:
            return _from_system_newlines(f.read()), encoding
1066069
private static String getEncodingToUse(String encoding)
    {
        //get encoding
        String updatedEncoding=encoding;
        if(updatedEncoding==null)
        {
            updatedEncoding=IOHelper.getDefaultEncoding();
        }
        
        return updatedEncoding;
    }
423456
def readFile(filename, encoding, options):
    
    ret = libxml2mod.xmlReadFile(filename, encoding, options)
    if ret is None:raise treeError('xmlReadFile() failed')
    return xmlDoc(_obj=ret)
890514
def read_file(file_name, encoding='utf-8'):
    
    with open(file_name, 'rb') as f:
        data = f.read()

    if encoding is not None:
        data = data.decode(encoding)

    return data
465120
def load(self, encoding='utf8', encoding_errors='ignore'):  # pylint: disable=arguments-differ
        
        if isinstance(self.codec, codec.NoCodec) and \
           self.fs.load_text != FileSystem.load_text:
            stream = self.fs.load_text(encoding, encoding_errors)
        else:
            stream = self.fs.load()
            stream = self.codec.decompress(stream)
            stream = TextIOWrapper(stream, encoding, encoding_errors)
        return stream
812395
def Read(self):
    
    encoded_string = self._file_object.readline()

    if isinstance(encoded_string, py2to3.UNICODE_TYPE):
      return encoded_string

    try:
      string = codecs.decode(encoded_string, self._encoding, self._errors)
    except UnicodeDecodeError:
      if self._errors == 'strict':
        logger.error(
            'Unable to properly read input due to encoding error. '
            'Switching to error tolerant encoding which can result in '
            'non Basic Latin (C0) characters to be replaced with "?" or '
            '"\\ufffd".')
        self._errors = 'replace'

      string = codecs.decode(encoded_string, self._encoding, self._errors)

    return string
1301891
def read(filename):
    
    fname = os.path.join(here, filename)
    with codecs.open(fname, encoding='utf-8') as f:
        return f.read()
657558
def _read_file(self, filename):
        

        if self.__compression:
            f = gzip.GzipFile(filename, "rb")
        else:
            f = open(filename, "rb")
        res = pickle.load(f)
        f.close()
        return res
130768
public static String readFile( String name ) throws IOException {
        StringBuilder b = new StringBuilder();
        BufferedReader r = new BufferedReader(new FileReader(name));
        String line;
        while( (line = r.readLine()) != null ) {
            b.append(line).append('\n');
        }
        r.close();
        return b.toString();
    }
1370413
def read(self, filename, encoding=None):
        
        with open(filename, encoding=encoding) as fp:
            self._read(fp, filename)
        self._filename = os.path.abspath(filename)
106145
def _readfile(self, filename):
        
        f = open(filename)
        self.content = f.readlines()
        f.close()
1348832
def safe_read_file(file_path: Path) -> str:
    
    for encoding in FILE_ENCODINGS:
        try:
            return file_path.read_text(encoding=encoding)
        except UnicodeError:
            pass  # Ignore encoding error

    raise GuesslangError('Encoding not supported for {!s}'.format(file_path))