Foreign languages and PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JoeT

    Foreign languages and PHP

    Hi...

    I'm trying to load in a text file using fgets into a database table.
    The text file contains a dictionary of terms in the form:

    <englishword>\t <spanishword>

    Problem is that the spanish words contain characters that are spanish
    specific, and when I read them in, they are converted into '?'.

    I don't want this.
    Any suggestions as to how to get around this?

    TIA,
    Joe

  • ashok

    #2
    Re: Foreign languages and PHP


    "JoeT" <trubisz@yahoo. com???????/???????? ? ???????? ?????????:
    news:1160505298 .122247.314790@ k70g2000cwa.goo glegroups.com.. .
    Hi...
    >
    I'm trying to load in a text file using fgets into a database table.
    The text file contains a dictionary of terms in the form:
    >
    <englishword>\t <spanishword>
    >
    Problem is that the spanish words contain characters that are spanish
    specific, and when I read them in, they are converted into '?'.
    >
    I don't want this.
    Any suggestions as to how to get around this?
    >
    TIA,
    Joe
    >
    what version of mysql you have?
    try default charset to utf8.


    Comment

    • Pedro Graca

      #3
      Re: Foreign languages and PHP

      JoeT wrote:
      Problem is that the spanish words contain characters that are spanish
      specific, and when I read them in, they are converted into '?'.
      >
      I don't want this.
      Any suggestions as to how to get around this?
      Use the same character set for input and output.
      If you got them as iso-8859-1 output them as iso-8859-1 (or convert)
      If you got them as utf-8 output utf-8 (or convert)



      <?php
      $charsets = array('iso-8859', 'utf-8', 'us-ascii', 'iso-2022-jp', 'koi8-r');
      $charset = $charsets[array_rand($cha rsets)];

      header('Content-Type: text/plain; charset=' . $charset);

      echo "Example of $charset\n\n\n" ;
      for ($i=0; $i<16; ++$i) {
      echo dechex($i), " :: ";
      for ($j=0; $j<16; ++$j) {
      echo chr($i*16 + $j);
      }
      echo "\n";
      }
      ?>


      Q: Why does my browser want to download this script when $charset is
      "iso-8859-1"? (That is why I reverted to "iso-8859" in the script).

      --
      File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

      Comment

      Working...