I wrote a quick plugin similar to the character limiter plugin, but for multibyte characters saved as entities in the database.
With text in a language that uses multibyte characters (for example, Japanese), using word/character trimming plugins may give you garbled text, especially near the last character (eg. “あ” might get trimmed to “&# 123” instead of giving the full “&# 12354;”). Your foreign characters are probably saved in the database as entities, which get trimmed.
The NB moji limit plugin allows you to trim foreign language characters correctly, without garbled text (known as mojibake in Japanese).
Usage
{exp:nb_moji_limit limit="10"}
あいうえおかきくけこさしすせそ
{/exp:nb_moji_limit}…would give
あいうえおかきくけこ…
Parameters
limit=”10”
Limits the number of multibyte characters (eg. 10 kana/kanji characters). Default is 50 characters.
encoding=”SJIS”
Sets the character encoding. Default is UTF-8.
tail=”—”
Adds characters at the end of the truncated string. Default is “…” (non-multibyte). Set to tail=”” to add nothing to the end of the string.
This came in handy with clients that were using ridiculously long entry/category titles in a foreign language, and therefore needed trimming 😊
Documentation (Developer’s site) Expression-engine.jp Forum (Japanese)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.