Visualizzazione dei risultati da 1 a 3 su 3

Discussione: utf8_to_unicode

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    184

    utf8_to_unicode

    Salve a tutti,
    ho trovato questa funzione che mi dovrbbe convertire i caratteri di una stringa da UTF8 a Unicode ma non funziona...

    function utf8_to_unicode($str) {

    $unicode = array();
    $values = array();
    $lookingFor = 1;

    for ($i = 0; $i < strlen($str); $i++ ) {

    $thisValue = ord( $str[ $i ] );

    if ( $thisValue < 128 ) $unicode[] = $thisValue; else {

    if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3;

    $values[] = $thisValue;

    if ( count( $values ) == $lookingFor ) {

    $number = ( $lookingFor == 3 ) ?
    ( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
    ( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );

    $unicode[] = $number;
    $values = array();
    $lookingFor = 1;

    } // if

    } // if

    } // for

    return $unicode;

    } // utf8_to_unicode

    $stringa = "vediamo se funziona";
    echo utf8_to_unicode($stringa);
    il risultato dell'echo è semplicemente Array

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    184
    up!

  3. #3

    Re: utf8_to_unicode

    Originariamente inviato da flander
    il risultato dell'echo è semplicemente Array
    evidentemente la funzione restituisce un array

    prova
    Codice PHP:
    print_r(...); 
    invece che echo
    There are 10 types of people in the world: Those who understand binary, and those who don't.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.