String length: Difference between revisions

m
(added PowerShell)
Line 458:
<lang java5>String s = "Hello, world!";
int byteCountUTF16 = s.getBytes("UTF-16").length;
int byteCountUTF8 = s.getBytes("UTF-8").length;</lang>>
===Character Length===
Java encodes strings in UTF-16, which represents each character with one or two 16-bit values. The most commonly used characters are represented by one 16-bit value, while rarer ones like some mathematical symbols are represented by two.
Anonymous user