title: Java String.getBytes("UTF8") JavaScript analog
body: <p><a href="https://codereview.stackexchange.com/questions/3569/pack-and-unpack-bytes-to-strings">Bytes to string and backward</a></p>
  
  <p>Functions written there work properly that is <code>pack(unpack("string"))</code> yields to <code>"string"</code>. But I would like to have the same result as <code>"string".getBytes("UTF8")</code> gives in Java.</p>
  
  <p>The question is how to make a function giving the same functionality as Java getBytes("UTF8") in JavaScript?</p>
  
  <p>For Latin strings <code>unpack(str)</code> from the article mentioned above provides the same result as <code>getBytes("UTF8")</code> except it adds <code>0</code> for odd positions. But with non-Latin strings it works completely different as it seems to me. Is there a way to work with string data in JavaScript like Java does?</p>