Press "Enter" to skip to content

Richy's Random Ramblings

Code Snippets: UTF-8 to UTF-16 revisited and expanded

Yes, I know I posted yesterday about converting from UTF-8 to UTF-16BE/UTF-16LE – but I wasn’t happy with the code to convert to UTF16. It relied on mb_convert_encoding which whilst clear, it did mean that sequences sent could be silently “fixed”, lone high/low surrogate code points would be refused to be output (which I actually needed as they were one thing I was trying to test against!), and I just wanted more “insight” into the whole UTF8 to UTF16 system.

Unicode is NOT UTF-8

One thing to remember (and which caused me a timesink) was that Unicode is NOT UTF-8! Unicode is a collection of characters which are usually represented in UTF-8 byte sequences (but can be represented in UTF-16BE/UTF-16LE and UTF32 and others).

Code Snippets: PHP: Converting to/from UTF-8 to UTF16-BE

I needed to convert some Unicode UTF16-BE strings (as used in Java) to UTF-8 (which is “byte-orientated” and so doesn’t need to worry about endianness) – however, there didn’t seem to many examples online. I’m not going to say these methods are robust, 100% accurate for every use case or even the best way to do it – but just ways to do it.

It’s worth noting that Java uses the escape sequence \uXXXX (where X is a hexadecimal code), and PHP uses the nearly similar escape sequence \u{XXXX} . Both seem to use \xXX for a single character.

ADDED: I’ve improved the UTF-8 to UTF-16 code conversion in a newer post.

Film Review: Superman (2025)

Red bold text reading "Superman"
Title drop!

Whilst I’m not quite managing to watch a film a week (my wife has been ill with, of all things, Kennel Cough – caught from one of our dog’s inoculations!), I have managed to finish watching Superman (2025) – you know the one with Nathan Fillion as Green Lantern/Guy Gardner, Alan Tudyk as Four/Gary, Bradley Cooper as Jor-El, Pom Klementieff as Five, and Sean Gunn as Maxwell Lord: surprisingly it was directed by James Gunn who did Guardians of the Galaxy. I wonder if he has any favourite actors… Oh, it also has David Corenswet as Superman and Nicholas Hoult as Luther.

Casting wise – I think they’ve got Jimmy Olson (Skyler Gisondo) spot on: Lex Luthor (played by 36 year old Nicholas Hoult) is too young and doesn’t quite have the gravitas for Luthor – he’s got the “Modern Doctor Who Master” villain issue of “make him over-excited/manic”: I can’t see how Luthor would have acquired all the funds and technology necessary with that sort of attitude (and age: even if he inherited a large portion). David Corenswet as Superman is okay – they’ve definitely gone for the Christopher Reeves look and feel for him (hair curl, shorts and even the classic theme) and Maria Gabriela de Faria as “The Engineer” (a nano-tech metahuman) has got the semi-mechnanicalish movement, but didn’t quite have the acting ability.

Film Review: The Naked Gun (2025)

A red firey background with metallic like text reading "The Naked Gun" the "UN" of gun is appears under the G at 90 degrees as the joke is they didn't leave enough space for it on the screen.
Title screen of The Naked Gun with the hilarious “error”where they ran out of screen space.

Looking for a film to watch for my (quite possibly short-lived) New Year’s resolution of watching at least one film a week, I stumbled upon the 2025 The Naked Gun with Liam Neeson and Pamela Anderson.

Whilst it is a continuation/sequel to the Leslie Neilsen movies, I can’t say the humour was there – I don’t think I laughed once. I did spend quite a lot of the movie thinking “Who is the actor playing Sig Gustafson” (answer: Kevin Durand – who played Vasiliy Fet in the excellent TV series “The Strain“), I didn’t recognise Pamela Anderson at all (despite being a young teen in the 80s/90s when Baywatch/Barbed Wire was available: neither really interested me, but the she was plastered everyway) and did have a bit of a smile when Weird Al’s customary Naked Gun cameo was made and a little smile when Dave Bautista made his small cameo – but that was about it.

Bug Report [Fixed]: WordPress Plugin “miniOrange Broken Link Checker” syntax errors

In an effort to prove to myself that I am actually trying to do work this month, I’m making a note of all the bugs in 3rd party software I find.

Today is a bug reported the developers of the miniOrange Broken Link Checker | Finder WordPress Plugin on the 11th June 2022 through the WordPress plugin forum about database syntax issues being caused in the version 2.1 of that plugin.