- == 系统问题,暂停聊天功能。==
- 【征集】西西河的经济学,及清流措施,需要主动参与者,『稷下学宫』新认证方式,24年网站打算和努力目标
主题:Unicode Characters in Java Source Code? -- johny
========================================================
1.5. Unicode Characters
Suppose we were defining a class that dealt with circles and we wanted a named constant that represented the value p. In most programming languages we would name the constant "pi" because in most languages identifiers (the technical term for names) are limited to the letters and digits available in the ASCII character set. In the Java programming language, however, we can do this:
class Circle {
static final double p = 3.14159265358979323846;
// ...
}
The Java programming language moves you toward the world of internationalized software: you write code in Unicode, an international character set standard. Unicode basic[1] characters are 16 bits, and together with the supplemental characters (21 bits) provide a character range large enough to write the major languages used in the world. That is why we can use p for the name of the constant in the example. p is a valid letter from the Greek section of Unicode and is therefore valid in source. Most existing code is typed in ASCII, a 7-bit character standard, or ISO Latin-1, an 8-bit character standard commonly called Latin-1. But these characters are translated into Unicode before processing, so the character set is always Unicode.
========================================================
上面这段文字是从The Java Programming Language(第4版)中摘录出来的。
上文中的= 3.14159265358979323846前面的p再原文中是希腊字母pi,圆周率的符号。
BBS发文没法显示出来,就变成p了。
好像意思是说,如果源文件中含有ascii以外的字符,也可以被JAVA的编译器顺利编译。
这点当然很好。
但是我想知道的是,在我输入源文件的时候,该怎样把圆周率这个符号输入我的文本编辑器中呢?(我用的是ULTRAEDIT)
- 相关回复 上下关系8
Unicode Characters in Java Source Code?
试验一下παβγδεζηθικλμνξοπρστυφχψωλ 鲈鱼 字52 2005-10-17 21:04:13
用软键盘就可以了吧? 1 伏波将军 字227 2005-10-14 05:43:03
😮不Work!没法编译通过! Highway 字371 2005-10-14 11:09:19
😄搞定了。变量名字甚至可以用中文,请看 1 Highway 字335 2005-10-14 11:59:29
😄酷啊,看来关键还是编译时的UTF-16这个参数 johny 字10 2005-10-16 23:11:38
有意思. 还从没注意过Java支持Unicode 同学 字31 2005-10-14 12:23:40
😁Java里面显示中文没有问题,我比较熟悉。 Highway 字104 2005-10-14 12:31:19