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
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
90
Content & Master Data Management with Pimcore
chluehr
1
760
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時代の品質責任と生産性
mfunaki
0
120
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.4k
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
930
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
150
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
9
6k
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
130
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
180
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
4
1.8k
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
130
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
500
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.6k
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
1
260
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Raft: Consensus for Rubyists
vanstee
141
7.6k
エンジニアに許された特別な時間の終わり
watany
108
250k
Being A Developer After 40
akosma
91
590k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
440
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Producing Creativity
orderedlist
PRO
348
40k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
620
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
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