Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Check reviews of PHP Web Hosting, compatible with Smarty Templates

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy wedding dresses on SiteSteer.com - Best Online Wedding Dress Store

Candy Crush Cheats

Tired of playing games? Visit the Game Supply to Sell World of Warcraft Accounts.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Chapter 11. Charset Encoding

Table of Contents

Charset Encoding

Charset Encoding

There are a variety of encodings for textual data, ISO-8859-1 (Latin1) and UTF-8 being the most popular. Unless specified otherwise with the SMARTY_RESOURCE_CHAR_SET constant, Smarty recognizes UTF-8 as the internal charset if Multibyte String is available, ISO-8859-1 if not.

Note

ISO-8859-1 has been PHP's default internal charset since the beginning. Unicode has been evolving since 1991. Since then it has become the one charset to conquer them all, as it is capable of encoding most of the known characters even accross different character systems (latin, cyrillic, japanese, …). UTF-8 is unicode's most used encoding, as it allows referencing the thousands of character with the smallest size overhead possible.

Since unicode and UTF-8 are very wide spread nowadays, their use is strongly encouraged.

Note

Smarty's internals and core plugins are truly UTF-8 compatible since Smarty 3.1. To achieve unicode compatibility, the Multibyte String PECL is required. Unless your PHP environment offers this package, Smarty will not be able to offer full-scale UTF-8 compatibility.

Example 11.1. Setting a different Charset Encoding


// use japanese character encoding
if (function_exists('mb_internal_charset')) {
  mb_internal_charset('EUC-JP');
}
define('SMARTY_RESOURCE_CHAR_SET', 'EUC-JP');
require_once 'libs/Smarty.class.php';
$smarty = new Smarty();
  
 

Comments
by Maurice on Apr 2, 2012 at 1:03
Shouldn't it be mb_internal_encoding? 8)
by Marcus Bointon on Feb 27, 2012 at 7:20
The code above appears to be wrong. There is no mb_internal_charset function - it should be mb_internal_encoding. It would probably be more useful to show what you'd need to set it to for Smarty2 compatibility, i.e. by using ISO-8859-1 as the example charset.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 6 plus 5? (Are you human?)

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
Buy from China @dhgate.com
dissertationteam.com
Buy Web Hosting @buy-hosting.net
WordPress Hosting Hub @wphostinghub.net