ASCII | x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF |
0x | tab, \t |
\n |
\r |
|||||||||||||
1x | esc |
|||||||||||||||
2x | space |
! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / |
3x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? |
4x | @ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
5x | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ |
6x | ` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o |
7x | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | |
8x | € | � |
‚ | ƒ | „ | … | † | ‡ | ˆ | ‰ | Š | ‹ | Œ | � |
Ž | � |
9x | � |
‘ | ’ | “ | ” | • | – | — | ˜ | ™ | š | › | œ | � |
ž | Ÿ |
Ax | ¡ | ¢ | £ | ¤ | ¥ | ¦ | § | ¨ | © | ª | « | ¬ | |
® | ¯ | |
Bx | ° | ± | ² | ³ | ´ | µ | ¶ | · | ¸ | ¹ | º | » | ¼ | ½ | ¾ | ¿ |
Cx | À | Á | Â | Ã | Ä | Å | Æ | Ç | È | É | Ê | Ë | Ì | Í | Î | Ï |
Dx | Ð | Ñ | Ò | Ó | Ô | Õ | Ö | × | Ø | Ù | Ú | Û | Ü | Ý | Þ | ß |
Ex | à | á | â | ã | ä | å | æ | ç | è | é | ê | ë | ì | í | î | ï |
Fx | ð | ñ | ò | ó | ô | õ | ö | ÷ | ø | ù | ú | û | ü | ý | þ | ÿ |
> echo -n "foo" | od -t cx1
0000000 f o o
66 6f 6f
0000003
> echo -n "是" | od -t x1The single character 是 (which hopefully isn't offensive or something!) is stored as three bytes: 0xe6, 0x98, and 0xaf.
0000000 e6 98 af
0000003
Name |
Header |
Open Binary File |
Read Binary Data |
Write Binary Data |
Seek |
Close File |
C Standard I/O |
#include <stdio.h> |
FILE *f=fopen("foo","rb"); |
int n=fread(buf,4,1,f); |
int n=fwrite(buf,4,1,f); |
fseek(f,0, SEEK_SET); |
fclose(f); |
C++ STL I/O |
#include <fstream> |
std::ifstream s("foo",std::ifstream::bin); |
s.read(buf,4); |
s.write(buf,4); |
s.seekg(0); |
/* automatic */ |
UNIX I/O |
#include <fcntl.h> |
int fd=open("demo",O_RDONLY); |
int n=read(fd,buf,4); |
int n=read(fd,buf,4); | lseek(fd,0, SEEK_SET); |
close(fd); |
Windows I/O |
#include <windows.h> |
HANDLE h=CreateFile(.....); |
int n=ReadFile(h,buf,...); |
int n=WriteFile(h,buf,...); |
SetFilePointer(h, 0,0, FILE_BEGIN); |
CloseHandle(h); |
me> cat newline_win.txtIn UNIX, '\n' starts a new line. '\r' can be used to overwrite the previous line if you really want to.
Hello
There!
me> od -t c newline_win.txt
0000000 H e l l o \r \n T h e r e ! \r \n
me> od -t c newline_unix.txtOn Macs, '\r' starts a new line.
0000000 H e l l o \n T h e r e ! \n
me> od -t c newline_mac.txtSo the same text file written on three different machines will contain three different sets of bytes at the end of a line!
0000000 H e l l o \r T h e r e ! \r