mb_convert_encoding

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

mb_convert_encodingConvert a string from one character encoding to another

Beschreibung

mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false

Converts string from from_encoding, or the current internal encoding, to to_encoding. If string is an Array, all its String values will be converted recursively.

Parameter-Liste

string

The String or Array to be converted.

to_encoding

The desired encoding of the result.

from_encoding

The current encoding used to interpret string. Multiple encodings may be specified as an Array or comma separated list, in which case the correct encoding will be guessed using the same algorithm as mb_detect_encoding().

If from_encoding is null or not specified, the mbstring.internal_encoding setting will be used if set, otherwise the default_charset setting.

See supported encodings for valid values of to_encoding and from_encoding.

Rückgabewerte

The encoded String or Array on success, Bei einem Fehler wird false zurückgegeben..

Fehler/Exceptions

As of PHP 8.0.0, a ValueError is thrown if the value of to_encoding or from_encoding is an invalid encoding. Prior to PHP 8.0.0, a E_WARNING was emitted instead.

Changelog

Version Beschreibung
8.0.0 mb_convert_encoding() will now throw a ValueError when to_encoding is passed an invalid encoding.
8.0.0 mb_convert_encoding() will now throw a ValueError when from_encoding is passed an invalid encoding.
8.0.0 from_encoding is nullable now.
7.2.0 This function now also accepts an Array as string. Formerly, only Strings have been supported.

Beispiele

Beispiel #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");

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

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Exploring the World of Wordle Unlimited: A Fun and Addictive Word Puzzle Experience

In recent years, word games have seen a resurgence in popularity, driven in large part by the viral success of Wordle, a daily word guessing game ...

Geschrieben von HarryCobb am 17.06.2025 04:28:41
Forum: PHP Developer Forum
The Ultimate Guide to Cookie Clicker: Master the Art of Cookie Production

Haha, Cookie Clicker – da kommen Erinnerungen hoch! Ich hab's „nur mal kurz“ ausprobieren wollen und plötzlich war der halbe Nachmittag weg ...

Geschrieben von benisfroms am 16.06.2025 11:35:55
Forum: Ankündigungen
IQOS iluma One:奢華便攜新體驗

九年前在首爾留學時,我第一次接觸到日本電子煙 (https://www.iqostw-shop.com/terea/heqb254v.html)。回國後,經朋友介紹 ...

Geschrieben von soothatshdlvs am 16.06.2025 08:16:03
Forum: Off-Topic Diskussionen