Come si converte un testo in esadecimale?
Codifica il testo in byte (UTF-8), poi scrivi ogni byte come due cifre esadecimali. "Hello" corrisponde ai byte 72, 101, 108, 108, 111, che in esadecimale sono 48 65 6C 6C 6F. Ogni cifra esadecimale rappresenta 4 bit, quindi un byte è sempre esattamente due cifre (00–FF).
Tabella esadecimale per lettere e cifre
| Car. | Hex | Car. | Hex | Car. | Hex |
|---|---|---|---|---|---|
| A | 41 | a | 61 | 0 | 30 |
| B | 42 | b | 62 | 1 | 31 |
| C | 43 | c | 63 | 2 | 32 |
| D | 44 | d | 64 | 3 | 33 |
| E | 45 | e | 65 | 4 | 34 |
| F | 46 | f | 66 | 5 | 35 |
| G | 47 | g | 67 | 6 | 36 |
| H | 48 | h | 68 | 7 | 37 |
| I | 49 | i | 69 | 8 | 38 |
| J | 4A | j | 6A | 9 | 39 |
| K | 4B | k | 6B | Spazio | 20 |
| L | 4C | l | 6C | . | 2E |
| M | 4D | m | 6D | , | 2C |
| N | 4E | n | 6E | ! | 21 |
| O | 4F | o | 6F | ? | 3F |
| P | 50 | p | 70 | ||
| Q | 51 | q | 71 | ||
| R | 52 | r | 72 | ||
| S | 53 | s | 73 | ||
| T | 54 | t | 74 | ||
| U | 55 | u | 75 | ||
| V | 56 | v | 76 | ||
| W | 57 | w | 77 | ||
| X | 58 | x | 78 | ||
| Y | 59 | y | 79 | ||
| Z | 5A | z | 7A |
Da testo a hex in Python, JavaScript ed Excel
| Dove | Testo → hex | Hex → testo |
|---|---|---|
| Python | "Hello".encode().hex() | bytes.fromhex("48656c6c6f").decode() |
| JavaScript | [...new TextEncoder().encode(s)].map(b=>b.toString(16).padStart(2,"0")).join("") | new TextDecoder().decode(Uint8Array.from(h.match(/../g),x=>parseInt(x,16))) |
| Excel | =DEC2HEX(UNICODE(A1)) per ogni carattere | =UNICHAR(HEX2DEC("48")) |
La funzione UNICODE di Excel restituisce il code point, che coincide con il byte UTF-8 solo per i caratteri ASCII.
Da hex a testo: quali formati sono accettati?
Coppie con spazi (48 65), una stringa continua (4865), stile C 0x48 0x65 ed escape \x48\x65. Virgole e due punti vengono ignorati.
Perché alcuni caratteri diventano 2–4 byte hex?
UTF-8 memorizza i caratteri oltre l'ASCII in più byte: "é" è C3 A9, "한" è ED 95 9C e "😀" è F0 9F 98 80.
Fonti: RFC 3629 (UTF-8) · Supporto Microsoft, funzione UNICODE. Verificato a ottobre 2026.