Measuring string length seems easy, but it’s such a nuanced trap. Here’s a string. Can you guess its length? “My 👨👩👦👦 is fun” It’s a trick question. There isn’t a single answer. In PHP, it’s 38. strlen($string) counts bytes in memory. In JavaScript, it’s 22. string.length counts UTF-16 code units. In Swift, it’s 11. string.count
Before Dennis Snell started talking to me about Unicode, I thought displaying text on a screen was the most boring thing. I had no clue. It’s fascinating! And I’m sharing my favorite bits below. Aha, if you wonder what are codepoints, code units etc. you may want to start with the short introduction to Unicode
I’m fascinated with Unicode. This blog post is one I wish I had 20 years ago when I was starting to learn about text encoding. Around 2005, I struggled to use Polish words on my website. I would type in koło in Windows notepad, but in Firefox I would see ko³o. Why? Notepad used the
We’ve had prepared statements for years, but the WordPress ecosystem still relies on mysqli_real_escape_string() and it’s scary. Can you find the security issue in this, deceivingly simple, code snippet? It’s related to text encoding. Adding backslashes to $_POST[‘new_content’] string can corrupt the data at best, and open up a SQL injection vulnerability at worst. Here’s
Dennis Snell and I want to sync two WordPress sites and we’ve been looking for a way to run a continuous content indexing in WordPress. One idea was to reuse the PHP process that renders the site and do a little bit of indexing after every page render. We’d need to flush all the buffers, ship the
Creating WordPress Playground helped me grow as an engineer, leader, and product person. This post, focusing on the engineering side, highlights the technical contributions I’m particularly proud of.
During my Christmas break, I’ve turned WordPress into a markdown editor, a git client, and a git server. It’s all dependency-free PHP code. It works in Playground, on any cheap hosting, and it could be merged into WordPress core. Why would I do that? I want Notion that’s free, offline first, and where I own
I’ve used Google Gemini to generate a MySQL query parser in PHP and I’ll tell you exactly how. It took two nights, ~$520, and yielded a 1MB MySQLParser.php file that worked out of the box, but not without bugs. This post is just a summary. If you want the full story. check out the original
This may be my last WordPress-related post until I’m back from my Sabbatical on September 26th. Enjoy! WebAssembly is easier than you think. It is difficult to get started with, but then it’s not. I’ve spent the last 10 months learning that, and now I will save you that time by sharing how to build
People are often surprised that the first prototype of WordPress Playground came together in just a week. It is so very tempting to wear my serious face and add something like oh, you know, that’s just experience and a few tricks from robust chaos theory. Some experience was involved, sure, but mostly tricks and chaos.