Skip to content

Commit d6285d5

Browse files
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

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
public class UniCode {
2-
public static void main(String args[])
3-
{
2+
public static void main(String args[]) {
43
char x = 0x03c8;
4+
55
for(char c = 0x0370; c <= 0x03FF; c++)
66
System.out.print(c + " ");
7+
78
for(char b = 0x0900; b <= 0x970; b++)
89
System.out.println(b);
910
}
10-
}
11+
}

0 commit comments

Comments
 (0)