08 — Resources¶
The primary sources¶
Everything in this library can be checked against these. Where a page says why, or since which version, it links one of them rather than paraphrasing it.
Ruby
String↗,Encoding↗ andRegexp↗ — the class documentation for Ruby 4.0.- Encodings ↗ — the language guide's page on the model behind chapter 01: string encodings, default external and internal, and transcoding options.
- Case mapping ↗ — the options
upcaseanddowncasetake, and what they do not support. - Command-line options ↗ —
-n,-p,-a,-F,-l,-i,-E,-W. - Packed data ↗ — every
packandunpackletter. - Character selectors ↗ — the
"a-z"and"^aeiou"arguments thattr,count,deleteandsqueezetake. - Onigmo's syntax reference ↗ — the regex engine's own description of
\h,\X, the POSIX brackets and(?u). - NEWS, release by release: 4.0.0 ↗ (Unicode 17.0), 3.4.0 ↗ (chilled literals,
append_as_bytes,Float("1.")), 3.2.0 ↗ (the regex cache,Regexp.linear_time?,Regexp.timeout). - Feature #20205 ↗ — chilled string literals, and the plan beyond them. Feature #19104 ↗ — the cache-based regex optimization.
Perl and Python
- perlunicode ↗ — including "The Unicode Bug" and
unicode_strings, from the case lesson. - perlre ↗, perlrun ↗, pack ↗ and perlop ↗ (indented here-docs, the magic increment).
- Python's
re↗.
Unicode, and the one security page
- UAX #29, Text Segmentation ↗ — grapheme clusters. UAX #15, Normalization Forms ↗.
- Rails security guide ↗ — its section on regular expressions is the anchors lesson with an attack attached.
Books¶
On the shelf beside this library, and worth the time:
- Text Processing with Ruby — Rob Miller (Pragmatic Bookshelf, 2015). Reading, parsing, transforming and writing text, at book length.
- Perl One-Liners: 130 Programs That Get Things Done — Peteris Krumins (No Starch Press, 2013). Most of them run under
ruby -norruby -pafter the small changes in the one-liner lesson. - Programming Ruby 1.9 & 2.0 — Dave Thomas, with Chad Fowler and Andy Hunt (Pragmatic Bookshelf, 2013). The "Pickaxe", written while the encoding model of chapter 01 was still new.
- The Ruby Programming Language — David Flanagan and Yukihiro Matsumoto (O'Reilly, 2008). Co-written by Ruby's author, as Ruby 1.9 arrived.
The same idea in the sibling libraries¶
Each row is a lesson here and its counterparts elsewhere. The Perl and Python comparisons are also inside the lessons themselves, as runnable programs.
The contrast is the point of having all of them. Ruby labels each string with an encoding; Perl keeps one flag, bytes or characters; Python keeps text and bytes in two types; Java and Rust fix one encoding inside every string — UTF-16 and UTF-8. Each choice buys something and costs something, and the rows above are where the costs show.
Tools worth having¶
ruby -W:deprecated— every deprecation warning, including mutation of a chilled literal.Regexp.linear_time?— in a test, next to every pattern that faces user input.xxdorod -c— the only reliable way to see a BOM, a stray\ror an invalid byte for what it is.perl -CSD— Perl with UTF-8 layers on standard streams and on files it opens, for comparing against Ruby without writingbinmode.