# Multibyte and declate (PHP5.4)

- Thread: https://externals.io/message/54510
- Original archive: https://news-web.php.net/php.internals/54510
- Started by Sebastian Krebs on 2011-08-11T20:11:36+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #54510 — Sebastian Krebs — 2011-08-11T20:11:36+00:00

URL: https://externals.io/message/54510#54510

Hi,

With PHP5.4 I get this warning

| Warning: declare(encoding=...) ignored because Zend multibyte feature
| is turned off by settings in [..]

because of

| declare(encoding = 'UTF-8');

An except from the manual [1]

> The encoding declare value is ignored in PHP 5.3 unless php is compiled with --enable-zend-multibyte.

Does this really means, that this declare statement is _ignored_, when 
PHP is _not_ compiled with "--enable-zend-multibyte", but it yields a 
warning (and not even just a notice), when it is (what is default now)? 
That feels a little bit inconsistent to me.

And btw: Its probably asked before, but is there a reason, why 
multibyte-support is disabled by default?

Regards,
Sebastian

[1] http://php.net/manual/en/control-structures.declare.php

---

## #54512 — Kalle Sommer Nielsen — 2011-08-11T21:56:35+00:00

URL: https://externals.io/message/54510#54512 · In reply to: #54510

Hi Sebastian

2011/8/11 Sebastian Krebs <sebastian.krebs.berlin@googlemail.com>:
> Hi,
>
> With PHP5.4 I get this warning
>
> | Warning: declare(encoding=...) ignored because Zend multibyte feature
> | is turned off by settings in [..]
>
> because of
>
> | declare(encoding = 'UTF-8');
>
> An except from the manual [1]
>

In PHP 5.4, the compile time switch was removed and made into an ini
directive, which lives under the name of zend.multibyte = [On|Off].

For the question about declare's availability: No Zend Multibyte
support does not make the engine ignore the construct totally, as we
also got another statement; ticks that can be used in declare aswell.

For the question about why its not enabled by default? Performance,
you don't want to enable multibyte support when most of your code
lives in a single byte char format anyway, some calls are most costly
because you can no longer jump just one byte and have to validate what
kind of character sequence we're at now.


-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #54513 — Sebastian Krebs — 2011-08-12T05:52:54+00:00

URL: https://externals.io/message/54510#54513 · In reply to: #54512

Hi,

2011/8/11 Kalle Sommer Nielsen <kalle@php.net>

> Hi Sebastian
>
> 2011/8/11 Sebastian Krebs <sebastian.krebs.berlin@googlemail.com>:
> > […]
>
> In PHP 5.4, the compile time switch was removed and made into an ini
> directive, which lives under the name of zend.multibyte = [On|Off].
>

Ah, I see. multibyte is either compiled in, or not (PHP5.3), or its either
enabled, or not (PHP5.4). Now I see a difference between "not compiled in"
(declare(encoding) is ignored) and "not enabled" (declare(encoding) throws a
warning).


> For the question about why its not enabled by default? Performance,
> you don't want to enable multibyte support when most of your code
> lives in a single byte char format anyway, some calls are most costly
> because you can no longer jump just one byte and have to validate what
> kind of character sequence we're at now.
>

This means, that either the file is ASCII and I should omit the
`declare(encoding)`-statement [1], or its not ASCII, but then -- when
multibyte is disabled -- I should not assume, that everything works fine?
That is, what the warning should tell me?


[1] Sidenote: Maybe it could ignore declare(encoding='ASCII') ;)


>
> --
> regards,
>
> Kalle Sommer Nielsen
> kalle@php.net
>


At all I think now, that the warning is probably the better reaction than
just doing nothing. No further question, thanks for that :)


Regards,
Sebastian
