Some bugs hide in dark corners.
Others spend years quietly turning:
Γ©
into:
ΓΒ©
This one had clearly studied at Hogwarts.
Mediabot has carried several historical UTF-8 workarounds over the years.
Commands containing accented characters could require local repairs, API queries sometimes needed mojibake recovery, and parts of the code still assumed that text coming from the database was made of raw UTF-8 bytes.
Before changing anything, we decided to stop guessing.
Two runtime probes were used to inspect both ends of the chain.
The first test checked the real production stack:
DBI 1.643
DBD::MariaDB 1.24
MariaDB correctly returned UTF-8 text as proper Perl character strings.
A real Γ© made the complete round trip correctly:
Perl character
β
MariaDB: C3 A9
β
Perl character: U+00E9
But feeding raw UTF-8 bytes directly to the driver reproduced the classic corruption:
C3 A9
β
C3 83 C2 A9
β
ΓΒ©
The database was therefore not the source of the curse.
The second probe inspected text immediately after it arrived from IRC.
For:
UTF8PROBE: Γ© Γ¨ Γ Γ§ Ε
Mediabot received:
utf8_flag=0
decode=valid_utf8_bytes
with perfectly valid UTF-8 bytes:
Γ© C3 A9
Γ¨ C3 A8
Γ C3 A0
Γ§ C3 A7
Ε C5 93
That was the missing piece.
IRC input entered Mediabot as UTF-8 bytes, while modern parts of the application β including DBD::MariaDB β expected proper Perl Unicode character strings.
Instead of adding another _repair_utf8_mojibake() spell somewhere deep inside a command, MB644 fixes the encoding boundary itself.
The intended flow is now:
IRC network
β
UTF-8 bytes
β
decode once
β
Perl Unicode strings
β
commands / database / APIs / Hailo
β
botPrivmsg()
β
encode once
β
IRC network
This gives Mediabot one consistent internal text representation instead of forcing individual commands to guess whether they received bytes or characters.
Existing decoding paths that would otherwise risk decoding the same text twice were adjusted accordingly.
Sensitive authentication paths were also kept isolated from this normalisation so that historical credentials are not silently transformed.
No database connection hacks.
No undocumented DBD::MariaDB attributes.
No database schema migration.
No mass conversion of existing data.
No attempt to hide mojibake by repairing every individual command.
And no reuse of an old MB number.
This is MB644, with the correction kept focused on the IRC UTF-8 boundary.
Targeted tests passed first.
Then the entire Mediabot test suite was run after the final correction:
RC=0
PASSED : 12889/12889 (900s)
12,889 tests passed. Zero failures.
The spell survived the full examination.
This is more than fixing an accented character in one command.
Mediabot now has a clearer contract:
That should make future encoding bugs considerably easier to understand β and much harder for ΓΒ© to escape from Azkaban again.
You must be logged in to reply.