Commit d6285d5
committed
feat: Add UniCode class to display Unicode character ranges
WHAT the code does:
- Defines a `UniCode` class with a `main()` method.
- Declares a character `x = 0x03c8` (Greek small letter psi) but doesn’t use it directly.
- Uses two loops to print Unicode ranges:
1. Greek and Coptic block (`0x0370` to `0x03FF`) → prints characters inline separated by spaces.
2. Devanagari block (`0x0900` to `0x0970`) → prints characters line by line.
WHY this matters:
- Demonstrates how to work with **Unicode literals** in Java.
- Shows that `char` in Java is a 16-bit Unicode code unit.
- Useful for understanding character encoding and supporting multiple languages/scripts.
HOW it works:
1. First loop prints Greek letters and symbols.
2. Second loop prints Devanagari script characters (used in Hindi and Sanskrit).
3. Output shows actual characters, not numeric codes.
Tips & gotchas:
- The loop variable must be `char`, otherwise printed values would be integers.
- The unused `x` variable could be printed to illustrate direct Unicode literal usage.
- Be mindful of console font/encoding → not all environments can render all Unicode characters.
- Java’s `char` covers only BMP (Basic Multilingual Plane). For characters outside BMP, `int` and surrogate pairs are needed.
Use-cases:
- Educational demo for **Unicode handling in Java**.
- Useful in text-processing, localization, and multilingual applications.
- Good for exploring character sets for different writing systems.
- Can be extended to print other Unicode ranges.
Short key: class-unicode-print-greek-devanagari.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent 4ef0c53 commit d6285d5
1 file changed
+4
-3
lines changedLines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
4 | 3 | | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
0 commit comments