Somewhere in most WooCommerce builds there is a catalog grid that clips product titles at 60 characters. English titles survive it. A Chinese title ends in half a glyph or the replacement character, because substr() counted 60 bytes and stopped in the middle of one three-byte character. This is where Chinese characters in WordPress usually break: at truncation rather than at input. There is no error, no log line, and usually no ticket.
An experiment Shuyang wrote up on Towards Data Science measured how much damage a character can take. He fed a small language model Chinese characters as grayscale images instead of token IDs, and the model still read them at 8×8 pixels per character. A version trained on images with half of each character cropped away lost less than 2% accuracy, by his numbers. The shape alone carries enough information to survive that kind of damage.
What the experiment showed
Tokenizing Chinese into IDs throws away the shapes. 打, 拍 and 拉 all carry the hand radical 扌, but as token IDs they are unrelated integers, so the model has to learn their family from co-occurrence alone. Rendering characters as pixels bakes that structure in before training starts. In Shuyang’s runs the visual model was twice as accurate as the text baseline after 0.4% of training steps, then the two converged to the same final accuracy. The early lead came from the prior. The gap closed because predicting the next character depends on which words appear together, not on which characters look alike.
Why nobody reports broken Chinese characters
The same redundancy that makes the experiment work makes the bug invisible. A reader who knows the script reads a clipped character the way the cropped-image model does, from the strokes that survived. The title is still legible and the customer still checks out, so the truncation sits in production for years. It surfaces much later, when someone measures something, or when the text ends up somewhere less forgiving than a browser.
Where the code splits a character in two
PHP string functions count bytes. In UTF-8 a Chinese character is three bytes, so substr() and strlen() are byte operations, and strrev will reverse a character into garbage. The usual places: a theme’s excerpt filter, a meta title clip, a payment gateway that truncates the order description, an export or feed script, an admin list column. MySQL full-text search is the other half of the problem. The default parser splits on whitespace, and Chinese text has none, so a FULLTEXT index matches almost nothing without the ngram parser.
What to change first
Use the mb_ functions wherever text can be non-ASCII, and pass the encoding explicitly, as the mb_substr manual shows. For clipping, this is the whole fix:
<?php
function bbioon_clip_title( string $text, int $max ): string {
if ( mb_strlen( $text, 'UTF-8' ) <= $max ) {
return $text;
}
return mb_substr( $text, 0, $max, 'UTF-8' ) . '…';
}For iteration, mb_str_split( $text, 1, ‘UTF-8’ ) yields whole characters instead of bytes. On the search side, build the index with WITH PARSER ngram and set ngram_token_size in my.cnf, since the parser indexes fixed-length character sequences rather than whitespace tokens. That is also where byte-level models beat LLMs for cross-script name search, for the same reason: names and radicals don’t survive fancy tokenization.
If your store sells into Chinese or Japanese markets and you keep finding clipped titles, or a search that misses half the catalog, that is the kind of cleanup I do, from template filters down to the index.
When readable isn’t correct
Slugs, exact matches against product codes, cross-script name matching, and any feed where the broken byte gets re-encoded downstream. A half character a human reads fine can turn into mojibake after one more encoding hop, because the cut sequence is no longer valid UTF-8. (I’m not sure the pixel findings transfer to Japanese kana, but the byte math does, since kana are also three bytes.) The cheap check is comparing strlen with mb_strlen on your title columns: identical numbers mean pure ASCII, a gap means the clip already happened somewhere.
Shuyang’s result says readers and models are forgiving about missing strokes, but your indexes and feeds are not. Run mb_check_encoding on anything that leaves the site, and validate the encoding instead of guessing, before a broken byte gets passed along a second time.