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
87
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
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
140
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
500
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
0
290
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
360
関数型プログラミングのメリットって何だろう?
wanko_it
0
180
act2-costs.pdf
sumedhbala
0
110
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
130
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
170
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.5k
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
Featured
See All Featured
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
Paper Plane (Part 1)
katiecoart
PRO
1
9.7k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
So, you think you're a good person
axbom
PRO
2
2.1k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
870
GitHub's CSS Performance
jonrohan
1033
470k
Thoughts on Productivity
jonyablonski
76
5.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.2k
The agentic SEO stack - context over prompts
schlessera
0
850
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