ASCII तालिका
128 ASCII वर्णों का पूर्ण संदर्भ दशमलव, हेक्स, अष्टाधारी और बाइनरी कोड के साथ।
128 वर्ण दिखाए गए
ASCII के बारे में
ASCII (American Standard Code for Information Interchange) सूचना विनिमय के लिए अमेरिकी मानक कोड, एक वर्ण एन्कोडिंग मानक है।
वर्ण श्रेणियाँ
- 0–31 · नियंत्रण वर्ण (अमुद्रणीय)
- 32 · स्पेस
- 33–47 · विराम चिह्न और प्रतीक
- 48–57 · अंक 0–9
- 65–90 · बड़े अक्षर A–Z
- 97–122 · छोटे अक्षर a–z
- 127 · DEL (हटाएँ)
ASCII और Unicode में क्या अंतर है?
ASCII 7 बिट्स पर 128 वर्णों को परिभाषित करता है। Unicode एक सुपरसेट है जो सभी लेखन प्रणालियों से 149,000+ वर्णों को कवर करता है। पहले 128 Unicode कोड पॉइंट ASCII के समान हैं।
मैं इन कोड्स को प्रोग्रामिंग में कैसे उपयोग करूँ?
JavaScript में: String.fromCharCode(65) → «A»। Python में: chr(65)। C में: (char)65। हेक्स मान एस्केप अनुक्रमों के साथ काम करते हैं: \x41 = «A»।
यह कैसे काम करता है
- पूरी तालिका देखें: सभी 128 ASCII अक्षर, code point (0 से 127) के क्रम में एक grid में दिखते हैं। प्रत्येक cell में visible character (या control codes के लिए उसका abbreviation), decimal code, और hex / octal / binary equivalents दिखते हैं।
- श्रेणी के अनुसार filter करें: dropdown से control characters (0-31), printable characters (32-126), letters, digits, या symbols तक सीमित करें। तब उपयोगी जब आप केवल, मान लें, punctuation block देखना चाहते हों।
- खोजें: search box character name («LF»), abbreviation, या numeric value (decimal या hex) से मिलाता है।
0x41,65, याAटाइप करने पर सभी एक ही cell पर पहुंचते हैं। - किसी cell पर click करें और उसके किसी भी representation को clipboard में copy करें। यह तब काम आता है जब आपको ANSI escape के लिए
\x1B, Unix newline के लिए0x0A, या space के लिए decimal32चाहिए।
ASCII का संक्षिप्त इतिहास
ASCII (American Standard Code for Information Interchange) को IBM इंजीनियर Bob Bemer ने मई 1961 में American Standards Association की X3.2 subcommittee को प्रस्तावित किया था, ताकि उस समय प्रचलित दर्जन भर असंगत character codes को एकीकृत किया जा सके। पहला published edition ASA X3.4-1963 था; lowercase letters 1967 के revision तक नहीं आए। यह standard तब से ANSI X3.4-1986 नाम से कई बार reaffirmed हो चुका है, और यह अपने international twin ISO/IEC 646 (और European ECMA-6) के माध्यम से हर आधुनिक character encoding का आधार बनता है।
Network उपयोग के लिए, ASCII को RFC 20, «ASCII format for Network Interchange,» द्वारा codified किया गया था, जो 16 अक्टूबर 1969 को publish हुई और UCLA में Vint Cerf द्वारा लिखी गई। RFC की recommendation («7-bit ASCII एक 8-bit byte में embedded, जिसका high-order bit हमेशा 0 होता है») अभी भी हर आधुनिक programming language और protocol के plain text के बारे में सोचने का तरीका है। 1968 में राष्ट्रपति Lyndon B. Johnson के executive order से US Federal Government ने 1 जुलाई 1969 से सभी federal computers पर ASCII support अनिवार्य कर दी, जिससे industry-wide adoption सुनिश्चित हुई।
सात Bits क्यों?
X3.2 committee दो अनाकर्षक विकल्पों के बीच फंसी थी। 6-bit code (ITA2 जैसे पुराने telegraph alphabets में प्रयुक्त) अविश्वसनीय था: एक noisy line पर single bit-flip, shift bit पर पड़ने पर, बाद के हर character को गलत decode कर सकता था। 8-bit code महंगी memory और slow modems के युग में फिजूलखर्ची लगती थी। समझौता था 7 bits = 128 code points, जिससे 8वां bit parity के लिए मुक्त रहता था। Parity bit को इस तरह set करना कि प्रत्येक byte में 1-bits की संख्या सम (या विषम) हो, single-bit transmission errors को 100% पकड़ लेता था, ठीक वही समस्या जो 1960s के acoustic couplers और serial cables पैदा करते थे।
जैसे-जैसे error rates घटे और modems तेज हुए, 8वें bit का पुनः उपयोग किया गया। विभिन्न national «extended ASCII» code pages (Latin-1, Windows-1252, Mac Roman, KOI8-R, …) ने accented letters और box-drawing characters के लिए codes 128-255 का उपयोग किया, लेकिन वे mappings परस्पर असंगत थे और अंततः Unicode और UTF-8 द्वारा विस्थापित हो गए।
Layout: 128 Code Points
7 bits = 27 = 128 distinct codes, जो 33 control characters (0-31 plus DEL at 127) और 95 printable characters (32-126) के रूप में व्यवस्थित हैं:
| श्रेणी | Hex | सामग्री |
|---|---|---|
| 0-31 | 00-1F | नियंत्रण characters (NUL, BEL, BS, HT, LF, CR, ESC, FS-US, …) |
| 32 | 20 | SPACE, printable किंतु invisible |
| 33-47 | 21-2F | विराम चिह्न: ! " # $ % & ' ( ) * + , - . / |
| 48-57 | 30-39 | अंक 0-9 |
| 58-64 | 3A-40 | अधिक विराम चिह्न: : ; < = > ? @ |
| 65-90 | 41-5A | बड़े अक्षर A-Z |
| 91-96 | 5B-60 | Brackets और accents: [ \ ] ^ _ ` |
| 97-122 | 61-7A | छोटे अक्षर a-z |
| 123-126 | 7B-7E | Curly braces और tilde: { | } ~ |
| 127 | 7F | DEL, «rub out» punched paper tape पर (binary 1111111) |
Control Characters जो अभी भी महत्वपूर्ण हैं
33 control characters में से अधिकांश teletype और paper-tape commands के रूप में उत्पन्न हुए और अब ऐतिहासिक जिज्ञासाएं हैं। कुछ अभी भी everyday computing में महत्वपूर्ण भूमिका निभाते हैं:
- NUL (0x00): C और किसी भी C-derived language में strings को terminate करता है। file path में embedded null paste करना पुराने code को crash करने का एक classic तरीका है।
- BEL (0x07,
\a): terminal beep। अभी भीprintf '\a'से triggered होती है। - BS (0x08,
\b): backspace। Progress-bar libraries द्वारा पिछली line overwrite करने के लिए उपयोग किया जाता है। - HT (0x09,
\t): horizontal tab। TSV files में उपयोग किए जाने वाले tab character और Python interpreter की अनंत indentation debate को परिभाषित करता है। - LF (0x0A,
\n): line feed। Unix newline। - CR (0x0D,
\r): carriage return। Windows newline का आधा भाग; progress bars में «line की शुरुआत पर लौटें» के लिए अकेले उपयोग किया जाता है। - ESC (0x1B,
\e/\x1B): escape character। Bemer का मूल आविष्कार, अब हर ANSI terminal escape sequence (colours, cursor movement, clear screen) का prefix। - FS / GS / RS / US (0x1C-0x1F): File / Group / Record / Unit separators। 1960s में record-oriented tape storage के लिए designed और काफी हद तक भुलाए गए, जब तक RFC 7464 «JSON Text Sequences» ने RS को streaming JSON records (
application/json-seq) के लिए prefix delimiter के रूप में वापस नहीं लाया। GS अभी भी कुछ retail barcode protocols में दिखता है। - DEL (0x7F): «rub out»। Teletype Model 33 की RUB OUT key ने code 127 भेजा क्योंकि binary में यह
1111111है: सभी सात bits set। paper tape पर कोई character delete करने के लिए, operator tape को पीछे ले जाता था और RUB OUT दबाता था, सभी existing holes में punch करते हुए। Receiver को all-1s वाले किसी भी byte को ignore करना था।
Line-Ending Wars
तीन platforms ने तीन अलग-अलग conventions चुनीं, और software तब से इसकी कीमत चुकाता रहा है। यांत्रिक उत्पत्ति typewriter और teletype में है, जहां दो अलग-अलग actions की जरूरत थी: carriage return print head को column 1 पर वापस लाता था, और line feed कागज को एक line आगे बढ़ाता था। अलग-अलग systems ने इसे एक byte या दो में encode करने के बारे में अलग-अलग निर्णय लिए:
| OS | Newline | बाइट्स | Escape |
|---|---|---|---|
| Unix / Linux / आधुनिक macOS | LF | 0x0A | \n |
| Classic Mac OS (OS X से पहले) | CR | 0x0D | \r |
| Windows / DOS | CRLF | 0x0D 0x0A | \r\n |
Internet protocols अधिकांशतः CRLF अनिवार्य करते हैं: HTTP, SMTP, FTP, MIME, और standard Internet Message Format सभी इसे निर्दिष्ट करते हैं। RFC 5322 स्पष्ट है: «CR and LF MUST only occur together as CRLF; they MUST NOT appear independently» message body में। Source code के अंदर, हालांकि, convention team के अनुसार भिन्न होती है, इसलिए git core.autocrlf ship करता है: Windows पर true के साथ, git files को working tree में CRLF के रूप में check out करता है लेकिन repo में LF के रूप में store करता है, ताकि हर platform पर same source file same blob hash produce करे। .gitattributes entry जैसे * text=auto project-level विकल्प है।
Terminal Colour के लिए ANSI Escape Sequences
Escape character (ESC, 0x1B), ANSI escape sequences का prefix है जो terminal output को colorize करते हैं। Standard ECMA-48 (1976) है, बाद में ANSI X3.64 के रूप में mirrored और ISO/IEC 6429 में शामिल। Grammar है ESC [ + parameters + एक final letter; ESC [ भाग को Control Sequence Introducer (CSI) कहा जाता है और language के आधार पर \e[, \x1b[, या \033[ के रूप में लिखा जाता है। Common Select Graphic Rendition codes:
0: reset / सामान्य ·1: bold ·4: underline ·7: reverse video30-37: अग्रभूमि रंग (black, red, green, yellow, blue, magenta, cyan, white)40-47: background colour (उसी क्रम में)90-97/100-107: चमकीला foreground / background
तो printf '\033[1;31mERROR\033[0m' «ERROR» bold red में print करता है और बाद में reset करता है। हर आधुनिक terminal emulator (और Windows Terminal 2019 से) इन्हें support करता है।
ASCII बनाम Unicode और UTF-8
ASCII 128 code points define करता है; Unicode 16.0 (2024 में released) 154,000 से अधिक cover करता है। crucial bridge है UTF-8, web पर dominant text encoding (~98% websites द्वारा 2026 में प्रयुक्त): UTF-8 इस प्रकार design की गई है कि कोई भी 7-bit ASCII byte (0x00-0x7F) वही character encode करती है जो हमेशा करती थी, high bit शून्य के साथ। व्यावहारिक परिणाम यह है कि हर valid ASCII file एक valid UTF-8 file भी है, byte-for-byte identical। 127 से ऊपर के Codepoints को multi-byte sequences (2 से 4 bytes) के रूप में encode किया जाता है, हर byte पर high bit set के साथ, जो guarantee करता है कि legacy ASCII parsers उन्हें ASCII characters के साथ कभी confuse नहीं करते।
सामान्य Programming Languages में ASCII
| भाषा | Code → अक्षर | अक्षर → Code |
|---|---|---|
| JavaScript | String.fromCharCode(65) | 'A'.charCodeAt(0) |
| Python | chr(65) | ord('A') |
| C / C++ | (char)65 | (int)'A' |
| Java | (char) 65 | (int) 'A' |
| Rust | char::from(65) | 'A' as u32 |
| Go | string(rune(65)) | int('A') |
| Bash / sh | printf '\x41' | printf '%d' "'A" |
| HTML | A या A | - |
| URL एन्कोडिंग | %41 = «A», %20 = स्पेस | - |
Case-Bit Trick
ASCII layout की एक छोटी लेकिन elegant property: uppercase letter और उसका lowercase counterpart ठीक एक bit में भिन्न होते हैं। A है 65 = 0100 0001; a है 97 = 0110 0001। केवल bit 5 भिन्न है। यह case-insensitive comparison को एक single bitwise operation बना देता है, x | 0x20 lowercase force करता है, x & 0xDF uppercase force करता है, दोनों lookup table से तेज। यह 1967 के revision में एक deliberate design choice था और एक कारण है कि layout कुछ जगहों पर «random» लगती है: यह alphabetical order ही नहीं, hardware-friendly properties भी encode करती है।
सामान्य गलतियां
- अंक 0 को NUL control character से confuse करना। NUL है code 0; character «0» है code 48। दोनों किसी भी programming language में interchangeable नहीं हैं।
- यह मानना कि एक byte एक character है। केवल ASCII text के लिए सच। UTF-8 text में variable-width characters होते हैं, इसलिए non-Latin scripts के लिए byte length और character count में बड़ा अंतर हो सकता है।
- एक file में line endings मिलाना। एक ही file में mixed CR / LF / CRLF कई parsers को confuse करती है और OS के अनुसार phantom blank lines या missing newlines produce करती है।
- C string termination में off-by-one। यह भूलना कि strings को trailing NUL के लिए एक extra byte चाहिए, मूल buffer-overflow vulnerability है।
- «Extended ASCII» को portable मान लेना। Codes 128-255 Latin-1, Windows-1252, KOI8-R, Mac Roman आदि में अलग-अलग characters हैं। UTF-8 एकमात्र safe आधुनिक विकल्प है।
- untrusted input में embedded ESC। यदि आप user-supplied data को sanitize किए बिना terminal पर log करते हैं, तो attacker ANSI escape sequences inject कर सकता है जो colour बदलें, cursor को move करें, या screen clear करें, जो कभी-कभी malicious content छुपाती हैं।
अक्सर पूछे जाने वाले प्रश्न
DEL का code 0 के बजाय 127 क्यों है?
क्योंकि 127 binary में 1111111 है: सभी सात bits set। punched paper tape पर कोई character delete करने के लिए, operator tape को पीछे ले जाता था और RUB OUT दबाता था, जो सभी existing holes में punch करता था। Receiver को all-1s वाले किसी भी byte को ignore करना था, इसलिए «deleted» character subsequent reads में invisible हो जाता था। यह convention पहले के teletype codes से inherited था।
«extended ASCII» क्या है और क्या इसे use करना safe है?
Standard ASCII code points 0-127 (7 bits) cover करता है। «Extended ASCII» शिथिल रूप से 8-bit encodings को संदर्भित करता है जो code points 128-255 को additional characters, Latin-1, Windows-1252, KOI8-R, Mac Roman और कई अन्य से भरती हैं। समस्या यह है कि extra characters प्रत्येक encoding में अलग-अलग meaning रखते हैं। यह नाम technically एक misnomer है (वे code pages ASCII standard के extensions नहीं हैं), और वे systems में safe नहीं हैं। UTF-8 आधुनिक, portable replacement है और original 0-127 range के साथ backwards-compatible है।
space (32) को «printable» क्यों माना जाता है यदि यह कुछ नहीं दिखाता?
क्योंकि यह printed line पर horizontal space लेता है, यह print head को ठीक वैसे ही आगे बढ़ाता है जैसे एक letter। इसके विपरीत, control characters visible output produce किए बिना device state बदलते हैं (BEL beep करता है, BS head को पीछे ले जाता है, LF कागज को आगे बढ़ाता है)। Classification इस आधार पर है कि character printer पर क्या करता है, न इस आधार पर कि उसका कोई glyph है या नहीं।
क्या CR और LF मेरे keyboard पर Enter के समान हैं?
अधिकांशतः हां, लेकिन आपका keyboard जो byte generate करता है वह OS पर निर्भर करता है। Windows पर, Enter दबाने से आमतौर पर CRLF (0x0D 0x0A) produce होती है; Linux और modern macOS पर, केवल LF (0x0A); classic Mac OS pre-X पर, केवल CR (0x0D)। कई editors file के existing line endings या configured project convention के आधार पर save पर इसे normalise करते हैं।
file/group/record/unit separators यहां क्यों हैं?
उन्हें 1960s में record-oriented tape storage के लिए design किया गया था, File > Group > Record > Unit। वे अधिकतर उपयोग से बाहर हो गए, लेकिन दो आश्चर्यजनक जगहों पर वापस आए: RFC 7464 «JSON Text Sequences» (media type application/json-seq) RS (0x1E) को streamed JSON records को delimit करने के prefix के रूप में उपयोग करता है, और retail barcode protocols में GS1 Application Identifier separator GS (0x1D) उपयोग करता है।
क्या ASCII 2026 में अभी भी relevant है?
बिल्कुल। हर आधुनिक protocol जो «text-based» है (HTTP headers, JSON, YAML, source code, command-line arguments, environment variables, DNS hostnames) ASCII range में काम करता है। UTF-8 arbitrary text के लिए dominant encoding है, लेकिन UTF-8 के पहले 128 byte values ठीक ASCII हैं, byte-for-byte। URL encoding से terminal colour से text-encoding bugs debug करने तक हर चीज के लिए तालिका जानना अभी भी आवश्यक है।