Read a blob from the database, encoding as necessary and translating from base64 if the IDB doesn't support native Blobs
194704
function readBlobData(body, type, asBlob, callback) {
  if (asBlob) {
    if (!body) {
      callback(pouchdbBinaryUtils.blob([''], {type: type}));
    } else if (typeof body !== 'string') { // we have blob support
      callback(body);
    } else { // no blob support
      callback(pouchdbBinaryUtils.base64StringToBlobOrBuffer(body, type));
    }
  } else { // as base64 string
    if (!body) {
      callback('');
    } else if (typeof body !== 'string') { // we have blob support
      pouchdbBinaryUtils.readAsBinaryString(body, function (binary) {
        callback(pouchdbBinaryUtils.btoa(binary));
      });
    } else { // no blob support
      callback(body);
    }
  }
}
996395
def read(self, encoding="utf8"):
        
        with open(self._filename, "rb") as f:
            if self.key:
                return get_module("mo_math.crypto").decrypt(f.read(), self.key)
            else:
                content = f.read().decode(encoding)
                return content
329207
def Read(self):
    
    input_string = self._file_object.readline()

    if isinstance(input_string, py2to3.BYTES_TYPE):
      try:
        input_string = codecs.decode(input_string, self._encoding, self._errors)
      except UnicodeDecodeError:
        if self._errors == 'strict':
          logging.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'

        input_string = codecs.decode(input_string, self._encoding, self._errors)

    return input_string
584203
public static byte[] readBlob(Object blob, boolean close) throws SQLException {
        byte[] result = null;
        InputStream input = null;

        //input = blob.getBinaryStream();
        try {
            input = (InputStream) MappingUtils.invokeFunction(blob, "getBinaryStream", new Class[]{}, new Object[]{});
        } catch (MjdbcException ex) {
            throw new MjdbcSQLException(ex);
        }

        result = toByteArray(input);

        if (close == true) {
            TypeHandlerUtils.closeQuietly(input);
        }

        return result;
    }
320823
function _decodeBlob(encodedBlob) {
    var arrayBuff = _binStringToArrayBuffer(atob(encodedBlob.data));
    return createBlob([arrayBuff], { type: encodedBlob.type });
}
663094
@Override
    public Blob convert(INDArray toConvert) throws SQLException {
        ByteBuffer byteBuffer = BinarySerde.toByteBuffer(toConvert);
        Buffer buffer = (Buffer) byteBuffer;
        buffer.rewind();
        byte[] arr = new byte[byteBuffer.capacity()];
        byteBuffer.get(arr);
        Connection c = dataSource.getConnection();
        Blob b = c.createBlob();
        b.setBytes(1, arr);
        return b;
    }
604826
function bytes2base64(buffer) {
            var str = '';
            var length;
            var i;
            // ArrayBuffer
            if (buffer instanceof ArrayBuffer) {
                length = buffer.byteLength;
                var view = new DataView(buffer, 0, length);
                for (i = 0; i < length; i++) {
                    str += String.fromCharCode(view.getUint8(i, false));
                }
            }
            // Array
            else if (buffer.length) {
                length = buffer.length;
                for (i = 0; i < length; i++) {
                    str += String.fromCharCode(buffer[i]);
                }
            }

            return btoa(str);
        }
810631
def decode_b64(data):
    ''''''
    byte_string = data.encode('utf-8')
    decoded = base64.b64decode(byte_string)
    return decoded.decode('utf-8')
1028316
def base64encode(_input=None):
    """"""
    if PY2:  # pragma: no cover
        return base64.b64encode(_input)
    elif PY3:  # pragma: no cover
        if isinstance(_input, bytes):
            return base64.b64encode(_input).decode('UTF-8')
        elif isinstance(_input, str):
            return base64.b64encode(bytearray(_input, encoding='UTF-8')).decode('UTF-8')
19960
def value_to_db(self, value):
        
        if isinstance(value, six.string_types):
            value = value.encode("utf_8")
        return value
374258
@Override
    public Blob getBlob(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            return new SerialBlob(table.getStringAsBytes(columnIndex - 1));
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
599172
public static Object convertBlob(Object blob, String value) throws SQLException {
        return convertBlob(blob, value.getBytes());
    }
1246511
def read_header(input)
      raise 'Not a Daybreak database' if input.read(MAGIC.bytesize) != MAGIC
      ver = input.read(2).unpack('n').first
      raise "Expected database version #{VERSION}, got #{ver}" if ver != VERSION
    end
343371
def decodeBase64(text, encoding='utf-8'):
    
    text = projex.text.toBytes(text, encoding)
    return projex.text.toUnicode(base64.b64decode(text), encoding)
1102248
def _read_json_binary_field(deserialized, field):
    ''' 
    '''
    val = deserialized.get(field)
    if val is not None:
        return utils.convert_to_bytes(val)
    val = deserialized.get(field + '64')
    if val is None:
        return None
    return utils.raw_urlsafe_b64decode(val)
926273
def __retrieve_internal_blob(self, key):
        ''' 
        '''
        logger = getLogger()
        with self.get_conn() as conn:
            try:
                c = conn.cursor()
                if key is None:
                    c.execute("SELECT compressed, blob_data FROM blob_entries WHERE KEY IS NULL")
                else:
                    c.execute("SELECT compressed, blob_data FROM blob_entries WHERE KEY = ?", (key,))
                result = c.fetchone()
                if not result:
                    logger.debug("There's no blob entry with key={key}".format(key=key))
                    logger.debug("result = {res}".format(res=result))
                    return None
                else:
                    compressed, blob_data = result
                    logger.debug("retrieving internal BLOB (key={key} | len={ln} | compressed={c})".format(key=key, ln=len(blob_data), c=compressed))
                    return blob_data if not compressed else zlib.decompress(blob_data)
            except:
                getLogger().exception("Cannot retrieve internal blob (key={})".format(key))
                return None
            return True
603935
public static String blobToStr(Blob blob, Charset charset) {
		InputStream in = null;
		try {
			in = blob.getBinaryStream();
			return IoUtil.read(in, charset);
		} catch (SQLException e) {
			throw new DbRuntimeException(e);
		} finally {
			IoUtil.close(in);
		}
	}