|
1 | | -Character code constants. |
| 1 | +-[](https://travis-ci.org/lrhn/charcode) |
| 2 | +-[](https://pub.dev/packages/charcode) - |
2 | 3 |
|
3 | | -[](https://travis-ci.org/dart-lang/charcode) |
4 | | -[](https://pub.dev/packages/charcode) |
| 4 | +# Character code constants |
5 | 5 |
|
6 | | -These libraries define symbolic names for some character codes. |
| 6 | +This package defines symbolic names for some character codes (aka. code points). |
7 | 7 |
|
8 | | -## Using |
| 8 | +They can used when working directly with characters as integers, |
| 9 | +to make the code more readable: `if (firstChar == $A) ...`. |
9 | 10 |
|
10 | | -Import either one of the libraries: |
| 11 | +This is not an official Google package, and is not supported by Google. |
| 12 | + |
| 13 | +## Usage |
11 | 14 |
|
| 15 | +Import either one of the libraries: |
12 | 16 | ```dart |
13 | 17 | import "package:charcode/ascii.dart"; |
14 | 18 | import "package:charcode/html_entity.dart"; |
15 | 19 | ``` |
16 | | - |
17 | 20 | or import both libraries using the `charcode.dart` library: |
18 | | - |
19 | 21 | ```dart |
20 | 22 | import "package:charcode/charcode.dart"; |
21 | 23 | ``` |
22 | 24 |
|
23 | | -# Naming |
| 25 | +## Naming |
24 | 26 |
|
25 | 27 | The character names are preceded by a `$` to avoid conflicting with other |
26 | | -variables due to the short and common names (for example "$i"). |
| 28 | +variables, due to their short and common names (for example "$i"). |
27 | 29 |
|
28 | | -The characters that are valid in a Dart identifier directly follow the `$`. |
| 30 | +Characters that are valid in a Dart identifier directly follow the `$`. |
29 | 31 | Examples: `$_`, `$a`, `$B` and `$3`. Other characters are given symbolic names. |
30 | 32 |
|
31 | | -The names of letters are lower-case for lower-case letters, and mixed- or |
32 | | -upper-case for upper-case letters. The names of symbols are all lower-case, |
| 33 | +The names of letters are lower-case for lower-case letters (`$sigma` for `σ`), |
| 34 | +and mixed- or upper-case for upper-case letters (`$Sigma` for `Σ`). |
| 35 | +The names of symbols and punctuation are all lower-case, |
33 | 36 | and omit suffixes like "sign", "symbol" and "mark". |
34 | | -Examples: `$plus`, `$exclamation` |
| 37 | +Examples: `$plus`, `$exclamation`, `$tilde`. |
35 | 38 |
|
36 | 39 | The `ascii.dart` library defines a symbolic name for each ASCII character. |
37 | | -For some characters, it has more than one name. For example the common `$tab` |
38 | | -and the official `$ht` for the horizontal tab. |
| 40 | +Some characters have more than one name. For example the common name `$tab` |
| 41 | +and the official abbreviation `$ht` for the horisontal tab. |
39 | 42 |
|
40 | 43 | The `html_entity.dart` library defines a constant for each HTML 4.01 character |
41 | | -entity, using the standard entity abbreviation, including its case. |
| 44 | +entity using their standard entity abbreviation, including case. |
42 | 45 | Examples: `$nbsp` for `&nbps;`, `$aring` for the lower-case `å` |
43 | 46 | and `$Aring` for the upper-case `Å`. |
44 | 47 |
|
45 | | -The HTML entities includes all characters in the Latin-1 code page, greek |
| 48 | +The HTML entities include all characters in the Latin-1 code page, greek |
46 | 49 | letters and some mathematical symbols. |
47 | 50 |
|
48 | | -The `charcode.dart` library just exports both `ascii.dart` and |
49 | | -`html_entity.dart`. |
| 51 | +The `charcode.dart` library exports both `ascii.dart` and |
| 52 | +`html_entity.dart`. Where both libraries define the same name, |
| 53 | +the HTML entity name is preferred. |
50 | 54 |
|
51 | | -# Rationale |
| 55 | +## Rationale |
52 | 56 |
|
53 | | -The Dart language doesn't have character literals. If that ever happens, this |
54 | | -library will be irrelevant. Until then, this library can be used for the most |
55 | | -common characters. |
56 | | -See [request for character literals](http://dartbug.com/4415). |
| 57 | +The Dart language doesn't have character literals. |
| 58 | +If that ever changes, this package will become irrelevant. |
| 59 | +Until then, this package can be used for the most common characters. |
| 60 | +See [http://dartbug.com/4415](request for character literals). |
0 commit comments