If I can understand the rules (please correct me if I am wrong):
\ OctalDigit Examples: \0, \1, \2, \3, \4, \5, \6, \7 \ OctalDigit OctalDigit Examples: \00, \07, \17, \27, \37, \47, \57, \67, \77 \ ZeroToThree OctalDigit OctalDigit Examples: \000, \177, \277, \367,\377
\t , \n , \\ do not fall under the rules of OctalEscape; they must be under separate escape character rules.
Decimal 255 is equal to Octal 377 (use the Windows calculator in scientific mode to confirm)
Therefore, a three-digit octal value falls in the range from \000 (0) to \377 (255)
Therefore, \4715 not a valid octal value, since this rule is greater than three octal digits. If you want to access a code point character with a decimal value of 4715, use the Unicode \u escape character to represent the UTF-16 \u126B (4715 in decimal), since each Java char is in Unicode UTF-16.
from http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Character.html :
The char data type (and therefore the value that the Character encapsulation object has) is based on the original Unicode specification, which defined characters as 16-bit fixed-width objects. Unicode has since been modified to require more than 16 bits for presentation. The point's legal code range is now U + 0000 to U + 10FFFF, known as the Unicode scalar value. (Refer to the definition of U + n notation in the Unicode standard.)
Many characters from U + 0000 to U + FFFF are sometimes referred to as basic multilingual aircraft (BMP). Characters whose code points are greater than U + FFFF are called extra characters. Java 2 uses the UTF-16 representation in char arrays and in String and StringBuffer. In this representation, additional characters are represented as a pair of char values, the first of the range of high surrogates, (\ uD800- \ uDBFF), the second of the range of low surrogates (\ uDC00- \ uDFFF).
Edited by:
Everything that exceeds the allowable octal value of the 8-bit range (more than one byte) depends on the language. Some programming languages may continue to fit the Unicode implementation; some cannot (limit one byte). Java definitely does not allow this, even if it supports Unicode.
Several vendor -specific programming languages that restrict single-byte octal literals :
- Java (all vendors): - an octal integer constant starting with 0 or one digit in the base-8 (up to 0377); \ 0 to \ 7, \ 00 to \ 77, \ 000 to \ 377 (in the format of an octal string literal)
- C / C ++ (Microsoft) - octal integer constant starting from 0 (up to 0377); Text string format
\nnn - Ruby - an octal integer constant starting with 0 (until 0377); Text string format
\nnn
Several programming languages (vendor-specific) that support more than one byte octal literals :
Several programming languages do not support octal literals :
- C # - use
Convert.ToInt32(integer, 8) for base-8 How can we convert a binary number to its octal number using C #?