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

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

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

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Chapter 11. 字符集编码

Table of Contents

字符集编码

字符集编码

有许多种文本数据的编码方式,ISO-8859-1 (Latin1) 和 UTF-8 是最常见的。 除非明确声明SMARTY_RESOURCE_CHAR_SET使用的字符集,默认 Smarty当遇到多字节字符情况 会使用UTF-8作为内置的字符集, 而当没有多字节字符情况下使用ISO-8859-1

Note

ISO-8859-1从开始就是PHP内置的默认字符集。 Unicode从1991年开始演变而来,而且逐渐替代了其他的字符集,因为其能对大多数已知的字符进行编码, 而且做到了跨各种不同字符集的系统(latin, cyrillic, japanese, …)。 UTF-8是unicode中使用的最多的编码,它可以用最小的尺寸提供成千上万的字符。

现在unicode和UTF-8已经非常流行了,所以强烈建议使用它们。

Note

从Smarty3.1开始,Smarty核心类和插件都被设计成兼容UTF-8的。 要做到良好的兼容性,最好开启多字节字符的PECL库。 除非PHP环境可以提供这个库,Smarty将不一定能完整兼容UTF-8。

Example 11.1. 设置字符集编码


// 使用日文字符集编码
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
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 5 plus 1? (Are you human?)

Advertisement