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: Iconvify (convert from one encoding to another for i18n)

Development and Programming

oli-studio's avatar
oli-studio
19 posts
16 years ago
oli-studio's avatar oli-studio

Hi All,

I made a small plugin that uses PHP’s iconv to convert from one encoding to another, eg UTF-8 to Shift-JIS. I needed this for the mobile section of a UTF-8-based Japanese website, as many Japanese cellphones only support Shift-JIS. I just wrapped the entire mobile template in this tag—it didn’t seem to make a noticeable speed difference. If anyone else out there is doing internationalization or localization this might help you.

Here are the docs:

Iconvify converts enclosed content from one text encoding to another using PHP’s iconv. This allows you to store data in your database using eg UTF-8, but still display it using a different encoding, such as Shift-JIS for Japanese mobile phones.

By default it converts from UTF-8 to Shift-JIS:

{exp:iconvify}
some UTF-8 text or tag output to convert to Shift-JIS
{/exp:iconvify}

You can override these using the parameters from=”” and/or to=”“:

{exp:iconvify to="iso-2022-jp"}
some UTF-8 text or tag output to convert to ISO-2022-jp
{/exp:iconvify}

When converting from UTF-8 to Shift-JIS it uses Nihonbunka’s tilde workaround (thanks!).

Please note that I haven’t yet used this in production (it worked fine in tests), and it’s my first plugin, so if you discover any problems or have suggestions please let me know. If the download link below doesn’t work, you can also grab it from here: oli-iconvify.0.1.zip

Changelog:

  • 2008-11-13 version 0.1 initial release (will update to 1.0 once I’m using it in production)
       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
16 years ago
Sean C. Smith's avatar Sean C. Smith

Wow, I’m sure I’ll find a use for this when I work on Korean web sites.

       
oli-studio's avatar
oli-studio
19 posts
16 years ago
oli-studio's avatar oli-studio

Hey Sean,

Thanks for your reply—I hope it’ll be of some use 😊

Does Korean have similar issues with some devices like cellphones not supporting UTF-8? I’m looking forward to the day of “UTF-8 and you’re done”!

peace - oli

       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
16 years ago
Sean C. Smith's avatar Sean C. Smith

The Korean internet is 100% borked. 99.7% IE, active X (can’t do anything without it) - I have no idea about cellphones and encoding but I imagine they don’t use utf8 because in my experience Korea rarely follows internation standards but instead does there own thing due to extreme nationalism.

       
oli-studio's avatar
oli-studio
19 posts
16 years ago
oli-studio's avatar oli-studio

wow :-| Sounds just like the Japanese web! hahaha. Well, Active-X isn’t so popular here, but apart from that…

Let me know if you find any bizarre encoding issues like the Shift-JIS tilde thing that need to be taken into account when you get round to using it.

peace - oli

       

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.