We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: NB moji limit

Development and Programming

Nicolas Bottari's avatar
Nicolas Bottari
143 posts
16 years ago
Nicolas Bottari's avatar Nicolas Bottari

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)

       
Pigtail Dencil's avatar
Pigtail Dencil
117 posts
16 years ago
Pigtail Dencil's avatar Pigtail Dencil

wow. nice!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.