r""" Reads text from a file. Automatically returns utf8.

    Args:
        fpath (str): file path
        aslines (bool): if True returns list of lines
        verbose (bool): verbosity flag

    Returns:
        str: text from fpath (this is unicode)

    Ignore:
        x = b'''/whaleshark_003_fors\xc3\xb8g.wmv" />\r\n'''
        ut.writeto('foo.txt', x)
        y = ut.readfrom('foo.txt')
        y.encode('utf8') == x

def read_from(fpath, verbose=None, aslines=False, strict=True, n=None, errors='replace'):
    r""" Reads text from a file. Automatically returns utf8.

    Args:
        fpath (str): file path
        aslines (bool): if True returns list of lines
        verbose (bool): verbosity flag

    Returns:
        str: text from fpath (this is unicode)

    Ignore:
        x = b'''/whaleshark_003_fors\xc3\xb8g.wmv" />\r\n'''
        ut.writeto('foo.txt', x)
        y = ut.readfrom('foo.txt')
        y.encode('utf8') == x
    """
    if n is None:
        n = __READ_TAIL_N__
    verbose = _rectify_verb_read(verbose)
    if verbose:
        print('[util_io] * Reading text file: %r ' % util_path.tail(fpath, n=n))
    try:
        if not util_path.checkpath(fpath, verbose=verbose, n=n):
            raise IOError('[io] * FILE DOES NOT EXIST!')
        #with open(fpath, 'r') as file_:
        with open(fpath, 'rb') as file_:
            if aslines:
                #text = file_.readlines()
                if six.PY2:
                    # python2 writes in bytes, so read as bytes then convert to
                    # utf8
                    text = [line.decode('utf8', errors=errors)
                            for line in file_.readlines()]
                else:
                    text = [line.decode('utf8', errors=errors)
                            for line in file_.readlines()]
                    #text = file_.readlines()
            else:
                # text = file_.read()
                if six.PY2:
                    text = file_.read().decode('utf8', errors=errors)
                else:
                    #text = file_.read()
                    text = file_.read().decode('utf8', errors=errors)
        return text
    except IOError as ex:
        from utool import util_dbg
        if verbose or strict:
            util_dbg.printex(ex, ' * Error reading fpath=%r' %
                             util_path.tail(fpath, n=n), '[io]')
        if strict:
            raise