How many bytes has a string in utf-8?
<p>i have this code in my program in java :</p>

<pre><code> public static int NumOfStringByte(String str) throws UnsupportedEncodingException{
        return str.getBytes("UTF-8").length+2;
    }
</code></pre>

<p>...
is this correct?
how can i calculate the number of bytes of a string?</p>