Greasemonkey: PHP multi-byte string warnings
Just a quick note to say that I released a new Greasemonkey script. It adds a warning box of text to any php.net manual page that features a function that is dangerous to multi-byte strings. I'm sorry, you want that in English? OK. Have you ever posted something to a Web site and found that characters were missing or truncated or there were lots of question marks or boxes where letters should have been? Usually that's because the person running the site doesn't understand how letters work at a programming-language level. They think everyone on Earth is using an English keyboard with the letters A-Z. When they get data that isn't A-Z, their Web site programs don't know what to do with the data, and they mangle it.
It turns out most people don't use just the A-Z characters, even people who write in English. Lots of people want to use the Euro symbol, for example. That isn't a "normal" letter, and so lots of Web sites just mangle it. Part of the problem is the programming language used on these Web sites. In particular, the PHP language has two main "modes" for handling characters. The first, and the default, is basically to treat everything like ASCII. ASCII is the A-Z standard. Unfortunately, that severely damages the text that people type nowadays. So PHP has a second major mode of operation, and that is to set itself to UTF-8. UTF-8 includes lots and lots of characters, and it's backwards compatible with ASCII. So pretty much every Web geek should use it.
The problem? The online PHP manual doesn't offer much of a warning any time you look up one of the old, bad ASCII functions. I personally replaced some old, bad code with... you guessed it... more old bad code. Why? Because I looked up replacement functions and found what I thought would work, only to realize that the replacement functions were also bad and came with NO disclaimer! And that leads us to my Greasemonkey script. This script will add disclaimers to php.net, on any page containing a bad old function. If possible it will also tell you a better way to do what you want to do. It's basically code help for PHP developers.
You can get the script on userscripts.org. Please install it and then view some of these pages to see the disclaimers it adds: