WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World
Convert character encoding

mb_convert_encoding

(PHP 4 >= 4.0.6, PHP 5)

mb_convert_encodingConvert character encoding

Description

string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] )

Converts the character encoding of string str to to_encoding from optionally from_encoding .

Parameters

str

The string being encoded.

to_encoding

The type of encoding that str is being converted to.

from_encoding

Is specified by character code names before conversion. It is either an array, or a comma separated enumerated list. If from_encoding is not specified, the internal encoding will be used.

"auto" may be used, which expands to "ASCII,JIS,UTF-8,EUC-JP,SJIS".

Return Values

The encoded string.

Examples

Example #1 mb_convert_encoding() example

<?php
/* Convert internal character encoding to SJIS */
$str mb_convert_encoding($str"SJIS");

/* Convert EUC-JP to UTF-7 */
$str mb_convert_encoding($str"UTF-7""EUC-JP");

/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
$str mb_convert_encoding($str"UCS-2LE""JIS, eucjp-win, sjis-win");

/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str mb_convert_encoding($str"EUC-JP""auto");
?>

See Also


Convert number to words
Categories : PHP, Math., Arrays
Function to convert Arabic numbers into Roman Numerals
Categories : Algorithms, PHP, Date Time
sec2hms : Convert number of seconds to HH:MM:SS format
Categories : PHP, Date Time



convert a number (three digits) to written form (English & Spanish)
Categories : PHP, Algorithms
Decimal to Fraction - A function that converts numbers with decimal remainders to numbers with fractional remainders.
Categories : PHP, Math.
File size with label - afunction that reads the filesize from a selected file and convert the number of bytes into KB, MB etc
Categories : PHP, Filesystem
A function that generates random numbers between 0 and 1 with precision that you set
Categories : PHP, Math.
EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly.
Categories : PHP, PHP Classes, Object Oriented, Graphics, GD image library
This is a simple date function. Its converts the date to e.g. maandag 03 januari 2000. The date will be stored in the $date string.
Categories : PHP, Date Time
BCrand, a function returns large random numbers
Categories : PHP, BC math, Algorithms
Convert text to 'quoted printable' without the IMAP package installed.
Categories : PHP, Mail, IMAP
Reduce the number of processors on a NT 4.0 system thru BOOT.INI
Categories : WinNT
A Simple Script that converts IP addresses to Color Codes -This function converts a given IP into a hex color. It changes according to ip input. Very useful to create customised pages.
Categories : PHP, BC math
mysql date/time converters, part II
Categories : PHP, MySQL, Databases, Date Time