Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Funzione per codifica utf-8

    Questo articolo spiega come gestire un sito con la codifica utf-8 .

    Si dice di filtrare tutte le stringhe non numeriche che provengono da moduli in questa funzione

    // FUNZIONE CHARSET PER CONVERTIRE DATI INVIATI DAGLI UTENTI
    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;

    }

    }

    }

    return $unicode;

    }

    Secondo voi è corretto? La funzione ritorna un array, come devo fare per leggerlo?

  2. #2
    up

  3. #3
    Help!

  4. #4
    Tento l'ultimo up. Se no mi trasformo in un pesce.

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.