title: Remove characters not-suitable for UTF-8 encoding from String
body: <p>I have a text-area on website where user can write anything. Problem happens when user copy paste some text or something which contains non-UTF 8 characters and submit them to server.</p>
  
  <p>Java successfully handles it, as it support UTF-16 but my mySql table support UTF-8 and thus insertion fails.</p>
  
  <p>I was trying to implement some way in business logic itself, to remove any characters which is not suitable for UTF-8 encoding.</p>
  
  <p>Currently I am using this code:</p>
  
  <pre><code>new String(java.nio.charset.Charset.forName("UTF-8").encode(myString).array());
  </code></pre>
  
  <p>But it replaces characters not suitable for UTF-8 with some other obscure characters. Which also does not look good to end user. Could someone please throw some light over any possible solution to tackle this using Java code?</p>
  
  <p><strong>EDIT :</strong> For example, exception I got while insertion of such values</p>
  
  <pre><code>java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8A\x0D\x0A...' for column
  
  java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x80\xF0\x9F...' for column
  </code></pre>