Home

mbinternalencoding

mb_internal_encoding is a function in PHP’s mbstring extension that gets or sets the internal character encoding used by multibyte string functions. It determines the default encoding for mbstring functions that do not receive an explicit encoding parameter, such as mb_strlen, mb_substr, and mb_strpos. The function is commonly referenced as mb_internal_encoding() in documentation.

When called without arguments, it returns the current internal encoding as a string. When called with a

The internal encoding can be configured via the mbstring.internal_encoding directive in php.ini, or at runtime with

Note that mb_internal_encoding() requires the mbstring extension. If mbstring is not loaded, the function is unavailable

Example: $enc = mb_internal_encoding(); mb_internal_encoding('UTF-8'); // now mbstring functions use UTF-8 by default. See also mb_detect_encoding and mbstring.

string
argument
specifying
an
encoding
(for
example
'UTF-8'),
it
sets
the
internal
encoding
to
that
value
and
returns
the
previous
encoding.
This
change
affects
subsequent
calls
to
many
mbstring
functions
that
rely
on
the
internal
encoding.
mb_internal_encoding().
Common
values
include
'UTF-8'
and
legacy
encodings
such
as
'ISO-8859-1'
or
'Shift_JIS'.
It
is
generally
recommended
to
use
UTF-8
for
modern
applications
to
maximize
compatibility
and
avoid
multibyte
parsing
issues.
and
multibyte-aware
functions
may
default
to
byte-oriented
behavior.
When
dealing
with
unknown
input,
mb_detect_encoding
can
help
determine
a
suitable
encoding
before
processing.