Wiki Markup |
---|
Every Java platform has a default character encoding. The available encodings are listed in the Supported Encodings document \[[Encodings 2006|AA. Bibliography#Encodings 06]\]. The default encoding is used whenConversion between characters and sequences of bytes requires a character is converted to a sequence of bytes and _vice versa_encoding to specify the details of the conversion. Such conversions use the system default encoding in the absence of an explicitly specified encoding. When characters are converted into an array of bytes to be sent as output, transmitted across some medium, input, and converted back into characters, the same encoding must be used on both sides of the conversation; disagreement over character encodings can cause data corruption. |
According to the Java API [API 2006] for the String
class:
The length of the new
String
is a function of the charset, and hence may not be equal to the length of the byte array. The behavior of this constructor when the given bytes are not valid in the given charset is unspecified.
Also, see See the related guideline FIO02-J. Keep track of bytes read and account for character encoding while reading data for more information.
Noncompliant Code Example
...
FIO03-EX1: An explicit character encoding may be omitted on the receiving side when the data was created by another Java application that both uses the same platform and and also uses the default character encoding.
...