Skip to content

Commit a30855a

Browse files
committed
feat(unicode): add UniCode demo for exploring Unicode character ranges
What - Introduced UniCode class to demonstrate working with Unicode characters in Java. - Prints: - Greek and Coptic characters from U+0370 to U+03FF. - Devanagari characters from U+0900 up to U+0970. - Declared a sample char `x = 0x03c8` (Greek letter psi). Why - Showcases how Java `char` type supports Unicode (16-bit, UTF-16). - Demonstrates direct use of Unicode code points via hexadecimal literals. - Provides practical insight into multilingual text handling in Java. How to use - Run UniCode. - Output will display: 1. Greek letters and symbols sequentially. 2. Devanagari script characters sequentially. Real-life applications - Rendering multilingual UIs (Greek, Hindi, etc.). - Handling internationalization (i18n) and localization (l10n). - Generating or parsing Unicode text for fonts, editors, or compilers. - Learning how Unicode blocks map to Java `char`. Notes - Java `char` represents UTF-16 code units (not full Unicode code points above U+FFFF). - For supplementary characters (outside BMP), use `int` and methods like `Character.toChars()`. - The loop with `0x0900` to `0x970` prints the Devanagari block, but should use `0x0970` (typo fix recommended). Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 00ced75 commit a30855a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Section26DateandTimeAPI/src/UniCode.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,31 @@ public static void main(String args[]) {
44

55
for(char c = 0x0370; c <= 0x03FF; c++)
66
System.out.print(c + " ");
7-
87
for(char b = 0x0900; b <= 0x970; b++)
98
System.out.println(b);
109
}
1110
}
11+
12+
/*
13+
1. Unicode Basics:
14+
- Java internally `char` ko Unicode (16-bit) ke form me store karta hai.
15+
- Iska matlab hai ki Java directly **multi-language support** deta hai (Greek, Hindi, Chinese… sab).
16+
17+
2. Code Explanation:
18+
- `char x = 0x03c8;`
19+
→ Unicode hexadecimal `0x03c8` ek Greek letter (ψ) ko represent karta hai.
20+
- `for (char c = 0x0370; c <= 0x03FF; c++)`
21+
→ Loop karega **Greek Unicode block (U+0370 to U+03FF)** ke saare characters print karne ke liye.
22+
- `for (char b = 0x0900; b <= 0x0970; b++)`
23+
→ Loop karega Devanagari Unicode block (U+0900 to U+0970)
24+
ke saare characters print karne ke liye (jaise: अ, आ, क, ख…).
25+
26+
3. Output Samajhne Layak:
27+
- Pehle loop Greek alphabets dikhayega.
28+
- Dusre loop Hindi/Devanagari script ke letters print karega.
29+
30+
4. Quick Recap:
31+
✔ Java ka `char` = Unicode support → ek character = 16-bit code point.
32+
✔ Unicode hexadecimal values likh ke alag-alag scripts print kar sakte ho.
33+
✔ Is program se tum Greek + Hindi alphabets console pe dekh paoge.
34+
*/

0 commit comments

Comments
 (0)