My Linux Fedora does not has a Chinese Input Bus. SO you know
First Generate a Binary file
[jjy@localhost binary]$ dd if=/dev/urandom of=testdata count=1
Go Code:
package main import( "fmt" //"bytes" "os" "io" ) func main(){ buffer := make([]byte,512) file,_ := os.Open("testdata") fileinfo,_:= file.Stat() filesize := fileinfo.Size() loop := filesize /512 fmt.Println(loop,filesize,len(buffer)) var i int64 for i=0;i<loop;i++{ io.ReadAtLeast(file,buffer,512) for j:=0;j<32;j++{ for k:=0;k<16;k++{ fmt.Printf("%02X ",buffer[16*j+k]) } fmt.Printf("\t") for k:=0;k<16;k++{ fmt.Printf("%c",buffer[16*j+k]) } fmt.Println() } } }
Result:
58 B1 E2 42 EB FD 19 CD 51 A1 C4 A7 58 63 DF FA X±âBëýÍQ¡Ä§Xcßú EA B3 22 68 9C 50 CB CE E3 EA 99 17 4A 52 5F 98 ê³"hœPËÎãê™JR_˜ 20 F3 24 D5 38 EE F7 67 4B F0 89 5B 91 60 41 6A ó$Õ8î÷gKð‰[‘`Aj F2 38 31 DB 3D 50 9A CE 7C 3C BC E8 F1 78 2F 1D ò81Û=PšÎ|<¼èñx/ 26 41 92 E8 03 39 7C 04 5A 4A 8A DA F3 6B 1A ED &A’è9|ZJŠÚókí 95 77 AA 9B 06 A1 22 92 26 21 1A DA ED 44 4C 83 •wª›¡"’&!ÚíDLƒ 0F D1 19 F7 C2 E6 86 5E B0 72 1A 7C A8 DA 41 20 Ñ÷Âæ†^°r|¨ÚA CF 84 B8 B6 08 08 3F 36 7E CA 88 26 B4 E3 72 29 Ï„?6~ʈ&´ãr)NYé DA 90 83 8C F8 F1 A3 DE 3A 28 12 DB 91 21 4E 18 ÚƒŒøñ£Þ:(Û‘!N AD 59 86 23 CD FD 77 45 5D 6B E4 57 EE AD 35 1B Y†#ÍýwE]käWî5 79 54 FF 4C CE 2D BA DB 13 06 0E 20 24 F1 26 D8 yTÿLÎ-ºÛ $ñ&Ø 48 ED 7E 67 1A F9 94 B0 C3 94 DC 2D D0 26 D5 77 Hí~gù”°Ã”Ü-Ð&Õw 8A 75 F9 97 E9 AE 04 0F 5F F0 E2 58 36 DE F4 BE Šuù—é®_ðâX6Þô¾ 4F 6F B2 97 DD 90 B3 9A 66 FA A0 C1 A9 B9 9B 47 Oo²—ݳšfú Á©¹›G 6C 85 3A 00 20 36 F0 4B DA 2F E3 D9 04 25 CC E6 l…: 6ðKÚ/ãÙ%ÌæJust For Fun
有疑问加站长微信联系(非本文作者)