PHP Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
mb_convert_encoding() and Other mbstring Functions
This section describes some basic functions provided in the mbstring extension library. mb_strlen() returns the number of characters. mb_convert_encoding() converts a string to a new encoding schema.
Let's first look at some of the basic "mbstring" functions offered in the "mbstring" extension library:
mb_get_info ( ) - Returns the current settings of "mbstring" extension.
mb_internal_encoding ( [string encoding] ) - Sets the current internal encoding with the specified encoding name. If no encoding is specified, it returns the current internal encoding.
string mb_strlen ( string str [, string encoding] ) - Returns the number of characters in the specified string based on the specified encoding name. If no encoding is specified, it uses the current internal encoding.
string mb_convert_encoding ( string str, string to_encoding [, mixed from_encoding] ) - Converts the specified string to a new encoding from an old encoding and returns the converted string. If no old encoding is specified, it uses the current internal encoding.
mb_detect_encoding ( string str ) - Detects and returns the encoding name of the specified string.
mb_http_input ( string type ) - Detects and returns the encoding name of the specified HTTP input type: "G" for GET, "P" for POST, "C" for COOKIE.
mb_http_output ( [string encoding] ) - Sets or returns the current HTTP output encoding.
mb_output_handler ( string contents, int status ) - Call back function for output buffer. When used as ob_start("mb_output_handler"), all strings going to the output buffer will be converted from the internal encoding to the HTTP output encoding.
mb_parse_str ( string encoded_string [, array &result] ) - Parses URL encoded strings, like the query string received with GET method. Resulting variables will be stored in the specified array. If no array is specified, resulting variables will be promoted into global variables.
Last update: 2019.
Table of Contents
Introduction and Installation of PHP 7.3
PHP Data Types and Data Literals
Variables, References, and Constants
Expressions, Operations and Type Conversions
Conditional Statements - "if" and "switch"
Loop Statements - "while", "for", and "do ... while"
Function Declaration, Arguments, and Return Values
Introduction of Class and Object
Integrating PHP with Apache Web Server
Retrieving Information from HTTP Requests
Creating and Managing Sessions in PHP Scripts
Sending and Receiving Cookies in PHP Scripts
Controlling HTTP Response Header Lines in PHP Scripts
MySQL Server Connection and Access Functions
Functions to Manage Directories, Files and Images
SOAP Extension Function and Calling Web Services
SOAP Server Functions and Examples
Localization Overview of Web Applications
Using Non-ASCII Characters in HTML Documents
Using Non-ASCII Characters as PHP Script String Literals
Receiving Non-ASCII Characters from Input Forms
►"mbstring" Extension and Non-ASCII Encoding Management
"mbstring" - Multi-Byte String Extension
►mb_convert_encoding() and Other mbstring Functions
Examples of Using "mbstring" Functions
Managing HTTP Input and Output Encoding
Managing Non-ASCII Character Strings with MySQL Servers