Skip to content

PHP 5.6/5.6: detect code impacted by the change in the default_charset value #839

@jrfnl

Description

@jrfnl

Just ran into this again in another project:

When using any of the iconv or mbstring functions which take a $charset or $encoding parameter in projects which have to be compatible with both PHP <= 5.5 as well as PHP 5.6, in most cases the results will only be the same if that (optional) parameter is set as otherwise the default encoding is used, as taken from the ini settings, and the default changed in PHP 5.6 (to utf-8).

This should be quite easily sniffable by searching for calls to these function and checking whether the parameter is set.

Refs:

Related PHP migration guide entries:

Default character encoding ¶

default_charset is now used as the default character set for the htmlentities(), html_entity_decode() and htmlspecialchars() functions. Note that if the (now deprecated) iconv and mbstring encoding settings are set, they will take precedence over default_charset for iconv and mbstring functions, respectively.

The default value for this setting is UTF-8.

Ref: https://www.php.net/manual/en/migration56.new-features.php#migration56.new-features.default-encoding

iconv and mbstring encoding settings ¶

The iconv and mbstring configuration options related to encoding have been deprecated in favour of default_charset. The deprecated options are:

`iconv.input_encoding`
`iconv.output_encoding`
`iconv.internal_encoding`
`mbstring.http_input`
`mbstring.http_output`
`mbstring.internal_encoding`

Ref: https://www.php.net/manual/en/migration56.deprecated.php#migration56.deprecated.iconv-mbstring-encoding

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions