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

    Creare file multilingua con fopen

    Ciao,
    sto realizzando un sito multilingua (utf-8). Finora tutto bene, ho solo un dubbio: dal pannello di amministrazione l'admin puo creare delle news che finiscono, anzichè in un db, in un file di testo.

    E' necessario in qualche modo impostare una codifica anche per questo file oppure basta che lo script che lo genera sia in una pagina utf-8?

  2. #2

  3. #3
    Grazie mille Filippo , solo a leggere questo post

    For those who, like me, lost a lot of minutes (hours) to understand why fwrite doesn't create a real utf-8 file, here's the explanation I've found :

    I tried to do something like this :
    <?php
    $myString = utf8_encode("Test with accents éèàç");
    $fh=fopen('test.xml',"w");
    fwrite($fh,$myString);
    fclose($fh);
    ?>

    For a mysterious reason, the resulted file shows the accent without the utf-8 conversion.

    I tried the binary, mode, etc. etc. And finally I've found it :
    It seems that fwrite NEEDS to have the utf8_encode function INSIDE its parameters like this, to understand it must create a non-text only file :
    <?php
    $myString = "Test with accents éèàç";
    $fh=fopen('test.xml',"w");
    fwrite($fh,utf8_encode($myString));
    fclose($fh);
    ?>
    penso che mi hai risparmiato qualche problema
    è che sul manuale ho cercato fopen e non fwrite
    sciaoo

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 © 2024 vBulletin Solutions, Inc. All rights reserved.