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
Character Building - Fun with charsets and enco...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Christoph Lühr
July 02, 2013
Programming
300
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Character Building - Fun with charsets and encodings
Christoph Lühr
July 02, 2013
More Decks by Christoph Lühr
See All by Christoph Lühr
Vektor-Suche & LLMs
chluehr
0
140
Search, Embeddings & Vector-DBs
chluehr
0
180
Reality Check: Automated Content Production at Enterprise Scale with Pimcore
chluehr
0
100
The how and why of getting Freelancers
chluehr
0
91
Content & Master Data Management with Pimcore
chluehr
1
770
Master Data Management with Pimcore
chluehr
0
230
Swoole in 5 Minutes [en]
chluehr
1
12k
PIM & Master Data Management with Pimcore 5 [en]
chluehr
2
340
Digital Transformation & Master Data Management with Pimcore 5
chluehr
0
270
Other Decks in Programming
See All in Programming
「人を評価する AI」の設計と実装
ryoyanara
0
180
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
450
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
490
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.1k
Google Apps Script で Ruby を動かす
kawahara
0
140
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
今さら聞けない .NET CLI
htkym
0
180
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.6k
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.7k
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
120
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
530
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
240
The Cult of Friendly URLs
andyhume
79
7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Music & Morning Musume
bryan
47
7.3k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Transcript
Christoph Lühr @chluehr / @bephpug 2013 "Fun with charsets and
encodings" Character Building ٩(͡๏̯͡๏)۶
basilicom
None
�
Image source: http://www.flickr.com/photos/stinajonsson/3932774410 CC BY-NC 2.0
Charset vs. Encoding
Set of Characters [ A B C ... 1 2
3 ... @#$ ] UNICODE / CODE PAGES
U+2278 NEITHER LESS-THAN NOR GREATER-THAN
U+2620 SKULL AND CROSSBONES
U+FDFA ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM "May Allah bless him
and grant him peace"
Encoding = Mapping A = 0x65 UTF-8, ISO-8859-1
Single Byte vs. Multi Byte
UTF-16 variable length!
UTF-16/32 Big- / vs Little-Endian
U+FEFF: BOM Byte-Order-Mark zero width non-breaking space
U+FFFE: BOM Byte-Order-Mark
BOM BOM BOM... UTF8 BOM 0xEF 0xBB 0xBF UTF32BE BOM
0x00 0x00 0xFE 0xFF UTF32LE BOM 0xFF 0xFE 0x00 0x00
How to debug? terminal.
hexdump -C foo.txt 00000000 48 61 6c 6c 6f 20
62 65 70 68 70 75 67 21 0a 48 |Hallo bephpug!.H| 00000010 69 65 72 20 65 69 6e 20 61 2d 55 6d 6c 61 75 74 |ier ein a-Umlaut| 00000020 3a c3 a4 21 0a 48 69 65 72 20 65 69 6e 20 61 2d |:..!.Hier ein a-| 00000030 6d 69 74 2d 4b 72 69 6e 67 65 6c 3a c3 a5 21 0a |mit-Kringel:..!.| 00000040 0a
How to re-encode? iconv -f FROM -t TO
PHP? strlen, substr, ...
� c3 a4 = ä c3 =
PHP! mbstring mb_* iconv_*
Transliteration ü => ue ü => u
Databases
DB - Connection SET NAMES 'UTF8'
DB - Storage Table vs. DB
DB - Collation ü..rstuvw ... rstuüvw
Problems Weird Stuff
PHP: Identifiers $Schüssel = new Müsli (T_FRÜCHTE); [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
Different Line-Endings
<?php CR LF LF // lets say hello! LF echo
"hello" LF
<?php CR LF LF // lets say hello! LF echo
"hello" LF <?php // lets say hello! LF echo "hello"
Diacritics ü => u+" U+00FC ü c3 bc LATIN SMALL
LETTER U WITH DIAERESIS U+0075 u 75 LATIN SMALL LETTER U U+0308 _̈ cc 88 COMBINING DIAERESIS
Advice
Use UTF-8
UTF-8
PHP/Server header( 'Content-type: text/html; charset=utf-8' ); HTML <meta http-equiv="Content-Type" content="
text/html; charset=UTF-8" >
Database SET NAMES UTF8 (or PDO) [mysql] default-character-set=utf8
Contact Christoph Lühr eMail:
[email protected]
,
[email protected]
Twitter: @chluehr Slides license
Attribution-NonCommercial-ShareAlike 3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/ Thanks! Questions? U+3020 POSTAL MARK FACE
Links • Kore Nordmann (FAQ!) http://kore-nordmann.de/blog/0082_charset_versus_encoding.html http://kore-nordmann.de/blog/php_charset_encoding_FAQ.html • Misc. Resources
http://www.iana.org/assignments/character-sets/character-sets.xml http://www.joelonsoftware.com/articles/Unicode.html http://www.unicode.org/charts/ http://t-a-w.blogspot.de/2008/12/funny-characters-in-unicode.html http://www.utf8-zeichentabelle.de/unicode-utf8-table.pl?number=1024 http://stackoverflow.com/questions/3417180/exotic-names-for-methods- constants-variables-and-fields-bug-or-feature