Dernière mise à jour: mer 17 fév 2010

unichr()

(PHP 4 >= 4.0.6, PHP 5)

Retourne un caractère à partir de son code UNICODE.

Retourne une chaîne d'un seul caractère, dont le code UNICODE est donné par le paramètre unicode.
Cette fonction complète la fonction uniord().

Source

<?php

function unichr( $unicode , $encoding = 'UTF-8' )
{
	return mb_convert_encoding("&#{$unicode};", $encoding, 'HTML-ENTITIES');
}

?>

Syntaxe

string unichr ( int $unicode [, string $encoding = 'UTF-8' ] )

Arguments

  1. unicode - Le code UNICODE.
  2. encoding - Le paramètre encoding est l'encodage des caractères. S'il est omis, l'encodage de caractères UTF-8 sera utilisé.

Valeurs de retour

Retourne le caractère à partir de son code UNICODE.

Voir aussi

  • chr() - Retourne un caractère à partir de son code ASCII
  • uniord() - Retourne le code UNICODE d'un caractère
  • uni_strlen() - Calcule la taille d'une chaîne UNICODE

Commentaire(s)

  • Yes is debatable, but I was corsndeiing this because:* it simpler to convert an existing ASCII application to UTF-8 that to UTF-32* sometime in the, far, future UTF-32 could be not enough, it did happened with UTF-16 before * with some luck you can convince ASCII applications to work with UTF-8 strings without breaking them. This would be clearly impossible with UTF-32* on average UTF-8 is consumes far less space than UTF-32.And about processing: I wouldn't even try to write my own UTF-8 string parsing routines there are good, free and open-source solutions for this.
  • tres interessant, merci

Poster un commentaire