title: convert blob(image) to varchar in oracle
body: <p>I am trying to read blob (image) from an oracle db and display it in html. The image is larger than the buffer size so I have to split it first and then append all the sub-strings. My approach is as below (there will be a loop to go through the blob):</p>
  
  <pre><code>SELECT utl_raw.cast_to_varchar2(dbms_lob.substr(FILE_CONTENTS,2000,1)) as mystring from doc where file_name='test.png'
  </code></pre>
  
  <p>The problem is that the converted string looks scrambled<a href="https://i.stack.imgur.com/LkTTX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LkTTX.png" alt="enter image description here"></a></p>
  
  <p>I did not specify the char_set for converting, could that be the reason? If so, how can I know which one to use?</p>
  
  <p>Thanks.</p>