Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
文字もじemojiよもやま話 / moji-moji-emoji
Search
ima1zumi
November 05, 2020
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
文字もじemojiよもやま話 / moji-moji-emoji
ima1zumi
November 05, 2020
More Decks by ima1zumi
See All by ima1zumi
Is Ruby's Multi-Encoding Overhead Heavy?
ima1zumi
1
3.1k
OSSと私たち: Rubyの開発を支える STORES
ima1zumi
2
180
Ruby Taught Me About Under the Hood
ima1zumi
6
24k
Exploring Reline: Enhancing Command Line Usability
ima1zumi
1
210
10年物のRailsアプリにキャッチアップ!〜コードを読まずに理解したかった〜
ima1zumi
0
190
RubyKaigiの登壇者一覧ページを作った
ima1zumi
0
710
Relineのその後の生活
ima1zumi
0
310
IRB and Reline Kaigi 2024
ima1zumi
0
68
Exploring Reline: Enhancing Command Line Usability
ima1zumi
3
16k
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
Agile that works and the tools we love
rasmusluckow
331
22k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
Google's AI Overviews - The New Search
badams
0
1.6k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
400
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
The Invisible Side of Design
smashingmag
301
52k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
We Have a Design System, Now What?
morganepeng
55
8.4k
Transcript
⽂字もじ emoji ⽂字もじ emoji よもやま話 よもやま話 2020-11-04 @ima1zumi 1
⾃⼰紹介 ✋ ⾃⼰紹介 ✋ @ima1zumi ( ❄) FJORD BOOT CAMP
で学習中 2
ある⽇のこと ある⽇のこと FJORD BOOT CAMP 質問・雑談タイムに参加 ⽂字コードの話になる 「" ".chars を実⾏してみるとおもしろいです
よ」 3
" ".chars => [" ", " ", " ", "
", " ", " ", " "] 4
なぜ .chars すると なぜ .chars すると ⼀家離散するのか ⼀家離散するのか 5
どう調べようか? どう調べようか? ⽂字コードを調べる 6
⽂字コードを⾒てみよう ⽂字コードを⾒てみよう 使うもの String#unpack unpack("U*") でUTF-8 のコードポイントに変換 String#to_s(16) 16 進数に変換
7
["1F468", "200D", "1F469", "200D", "1F466", "200D", "1F466"] " ".unpack("U*").map{_1.to_s(16).upcase} =>
["3042"] " ".unpack("U*").map{_1.to_s(16).upcase} => ["1F468", "200D", "1F469", "200D", "1F466", "200D", "1F466"] 8
1つ1つ⾒てみよう 1つ1つ⾒てみよう ⽂字コードから⽂字になおしたい Array#pack を使う コードポイントの前に0x をつける "\u{1F468}" でもOK 9
⽂字コードから⽂字に変換 ⽂字コードから⽂字に変換 " ".unpack("U*").map{"U+#{_1.to_s(16).upcase}"} => ["U+1F468", "U+200D", "U+1F469", "U+200D", "U+1F466",
"U+200D", "U+1F466"] [0x1F468].pack("U*") => " " [0x200D].pack("U*") => " " [0x1F469].pack("U*") => " " [0x1F466].pack("U*") => " " 10
わかったこと わかったこと " " は [" ", " ", "
", " ", " ", " ", " "] でできてい た なぜこうなる? 11
字 字 ⽂字と⽂字を組み合わせて作られる⽂字 組み合わせるために特殊な⽂字が使われる 家族の絵⽂字の場合は Zero width Joiner(ZWJ) ゼロ幅接合⼦ ["
", " ", " ", " ", " ", " ", " "] の "" が ZWJ 12
ZWJ を使った絵⽂字の例 ZWJ を使った絵⽂字の例 13
特殊な絵⽂字たち 特殊な絵⽂字たち 国旗 ⽂字と絵⽂字 ❤ ❤ 肌⾊ 特殊なのでわりと壊れがち 14
chars で⼀家離散した理由 chars で⼀家離散した理由 A. そもそも別々の⽂字だから 15
ところで ところで " " は何⽂字ですか? 16
7 ⽂字? " ".length => 7 " ".chars => ["
", " ", " ", " ", " ", " ", " "] 17
質問2 質問2 " が" は何⽂字ですか? 18
結合⽂字の " が" 2 ⽂字? " ".length => 2 "
".chars => [" ", ゙ "] 19
⾒た⽬1⽂字だから ⾒た⽬1⽂字だから 1⽂字で扱いたい 1⽂字で扱いたい 20
⼀家離散を防ぐ⽅法 ⼀家離散を防ぐ⽅法 A. String#grapheme_clusters を使う " ".grapheme_clusters => [" "]
21
grapheme grapheme 書記素クラスタ Unicode において、⾃然な1⽂字を表す単位 22
「⽂字」は⾃明な単位ではない 「⽂字」は⾃明な単位ではない 「1⽂字」として扱いたいのは なのか、な のか? 厳密に「⾒た⽬の1⽂字」を扱いたいなら書記 素を単位とする 23
⾒た⽬の1⽂字と ⾒た⽬の1⽂字と ⽂字コードの1⽂字 ⽂字コードの1⽂字 は違うことがある は違うことがある 24