aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/programmers/charset.md
blob: 72842b3f7df566ca8083f1820e3d11f21b413e74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Charset Encoding {#charset}
================

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](https://www.php.net/mbstring) 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](https://www.php.net/mbstring) PECL is required. Unless your PHP
> environment offers this package, Smarty will not be able to offer
> full-scale UTF-8 compatibility.


    // 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();