西西河

主题:Unicode Characters in Java Source Code? -- johny

共:💬15 🌺2 新:
分页树展主题 · 全看首页 上页
/ 1
下页 末页
  • 家园 Unicode Characters in Java Source Code?

    ========================================================

    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)

分页树展主题 · 全看首页 上页
/ 1
下页 末页


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河