• Post Reply Bookmark Topic Watch Topic
  • New Topic

What diff between String.getBytes(UTF8) & String.getBytes(UTF16)  RSS feed

 
Javan Li
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thx!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Intermediate forum...
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, assuming UTF8 and UTF16 are references to Strings "UTF-8" and "UTF-16" - the first converts the String to a sequence of bytes using UTF-8 format, while the second uses UTF-16 format. UTF-8 uses from 1 to 3 bytes for characters, while UTF-16 uses 2 bytes for each char. (At least, all chars in the range Java can handle.) See here and here for more info.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!