Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ASCIIコードの小話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Osumi, Yusuke
April 17, 2021
Technology
470
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ASCIIコードの小話
「新しいLinuxの教科書」を読む会 オンライン #12 での発表資料です。
https://linuxbook.connpass.com/event/208181/
Osumi, Yusuke
April 17, 2021
More Decks by Osumi, Yusuke
See All by Osumi, Yusuke
本の紹介の補足
ozuma
1
420
gitサービス3兄弟
ozuma
0
430
簡体字は楽
ozuma
0
500
ソフトウェアは固定資産
ozuma
0
450
今いるディレクトリを消すとどうなる
ozuma
1
430
名前付きパイプ FIFO
ozuma
0
580
文章、作文技法 リモートワーク
ozuma
1
950
CentOSの今後のリリース(簡易説明)
ozuma
0
430
AndroidでもLinux動いてるよ
ozuma
0
460
Other Decks in Technology
See All in Technology
JAWS-UG初心者支部#88わいわい初心塾(夏休みの宿題やったかGit編)
otsuki
0
120
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
870
プロダクトエンジニアに必要な「いい感じ」に作る能力 〜たくさん作れる時代に、どこまで作るかの決め方〜
jnishime_dresscode
2
1.3k
はじめてのDatabricks:技術者向けワークショップ / beginner-workshop
databricksjapan
PRO
0
150
V8コントリビュート超入門
riyaamemiya
0
140
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
110
動画配信アプリでの Engage SDK 導入 — TVer Android が Play ストアにコンテンツを届けるまで
techtver
PRO
0
110
[RSJ26] Building a VLA Model Based on Self-Distilled Classification
keio_smilab
PRO
0
190
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
260
Bet AI Day 2026丨Agentは、「金融」という巨大産業の何を変えられるのか
layerx
PRO
0
770
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
220
PdMをやめて、 "プロダクトビルダー"という 働き方に変えました / PdM to Product Builder
shikichee
2
700
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
55
8.3k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
840
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
From π to Pie charts
rasagy
0
350
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
330
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
520
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Accessibility Awareness
sabderemane
1
200
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Transcript
ASCIIコードの小話 @ozuma5119 1 「新しいLinuxの教科書」を読む会 オンライン #12 2021/04/17
2 コンピュータの中では、 すべてが0(ゼロ)と1(イチ)で 表され…… 本当かなぁ……? コマンドだってechoとか アルファベットになってるし……
ゼロとイチで見てみよう - xxdコマンド $ cat sample.txt zshell is great. $
xxd -b sample.txt 0000000: 01111010 01110011 01101000 01100101 01101100 01101100 zshell 0000006: 00100000 01101001 01110011 00100000 01100111 01110010 is gr 000000c: 01100101 01100001 01110100 00101110 00001010 eat.. 3 アドレス データ部 ASCII表示
もうちょっと細かく $ cat sample.txt zshell is great. $ xxd -b
sample.txt 0000000: 01111010 01110011 01101000 01100101 01101100 01101100 zshell 0000006: 00100000 01101001 01110011 00100000 01100111 01110010 is gr 000000c: 01100101 01100001 01110100 00101110 00001010 eat.. 4 01111010 (2進数表現) 0172 (8進数表現、アタマに0を付ける) 122 (10進数表現) 0x7A (16進数表現、アタマに0xを付ける)
5 https://en.wikipedia.org/wiki/ASCII
$ man ascii 6 Oct Dec Hex Char Oct Dec
Hex Char ------------------------------------------------------------------------ 000 0 00 NUL '\0' 100 64 40 @ 001 1 01 SOH (start of heading) 101 65 41 A 002 2 02 STX (start of text) 102 66 42 B 003 3 03 ETX (end of text) 103 67 43 C 066 54 36 6 166 118 76 v 067 55 37 7 167 119 77 w 070 56 38 8 170 120 78 x 071 57 39 9 171 121 79 y 072 58 3A : 172 122 7A z .... .... 8進数 表現 10進数 表現 16進数 表現 ASCII文字 表現
つまづきやすいポイント 7 なんで8進数にしたり16進数に したりするの? A. 見やすいから。それだけ。 ぜんぶゼロとイチなら、すべて 2進数表現でいいのでは? A. 長すぎてダルいので16進数で短く書きたい。
それだけ。
8 https://en.wikipedia.org/wiki/File:Harddrive-engineerguy.ogv ハードディスクドライブ → 磁気記録 https://ja.wikipedia.org/wiki/NAND%E5%9E%8B%E3%83% 95%E3%83%A9%E3%83%83%E3%82%B7%E3%83%A5 %E3%83%A1%E3%83%A2%E3%83%AA SSD →
電荷記録
9 コンピュータの中では、 すべてが0(ゼロ)と1(イチ)で 表され…… 本当です
ASCIIコードもうちょっと 制御コード(コントロールコード) 10 Oct Dec Hex Char ------------------------------------------- 010 8
08 BS '\b' (backspace) 011 9 09 HT '\t' (horizontal tab) 012 10 0A LF '\n' (new line) 013 11 0B VT '\v' (vertical tab) 014 12 0C FF '\f' (form feed) 015 13 0D CR '\r' (carriage ret)
ASCIIコードもうちょっと 制御コード(コントロールコード) 11 Oct Dec Hex Char ------------------------------------------- 012 10
0A LF '\n' (new line) 015 13 0D CR '\r' (carriage ret) どちらも改行だが、テレタイプ時代の名残りがある LF = ラインフィード。タイプライターの紙を1行送る CR = キャリッジリターン。タイプライターのヘッドを先頭に戻す
catで見えない文字を埋め込む 12 $ cat ascii.txt Hello, World! $ xxd ascii.txt
0000000: 4141 410d 4865 6c6c 6f2c 2057 6f72 6c64 AAA.Hello, World 0000010: 210a 編集のしかた: vim -b ascii.txt :%!xxd :%!xxd -r キャリッジリターンでカーソルを 先頭に戻すと、catではそこまでの 文字が消える
DEL は 0x7F (01111111) ASCIIは本来7bitで、テープに穴を開けてビット表現 失敗した文字は、テープの全部に穴を開けることでDELを 表現できる 13 https://en.wikipedia.org/wiki/Delete_character