Hello,

This is nothing extra, I run a query in a node:


$s = "
	
SELECT `title`FROM `node`
";

$events=mysql_query($s);


	
	while ($line = @mysql_fetch_array($events, MYSQL_ASSOC)) 
  {
  foreach ($line as $col_value=> $value) 
     {
      $$col_value= $value;
     echo $col_value, ": ", $value, "<br><br>";
  }


  
  
  
}

echo "áéőóúűüö";


The first echo which contains these ISO-8859-2 characters are replaced by question marks.
The second echo just prints out fine as it is.

The page default charset setting is UTF-8 and there is no way to change that because that would mess up the whole page.

But this does not make any sense why whould the character change if it is comming from a query??

Any suggestion?

Thanks

Comments

mickh’s picture

Is your database set up to handle UTF8 characters?
I'm not strong on details, but I know that PHP can also have UTF8 issues, which are often solved using the mbstring extension.

vojnar’s picture

Hi,

Ok seems like if we are getting a query results (ISO-8859-2) set in a char set which is not an UTF-8 then we have to convert it to UTF-8 and have drupal render it back to ISO-8859-2 when it prints it to the screen. This is a little bit crazy but this is how it works.
The result achived by using iconv.

This is the correct code running 

$s = "SELECT `title`FROM `node`";
$events=mysql_query($s);
while ($line = @mysql_fetch_array($events, MYSQL_ASSOC)) 
  {
  foreach ($line as $col_value=> $value) 
     {
      $$col_value= $value;

$value=iconv("iso-8859-2", "utf-8",$value);
     echo $col_value, ": ", $value, "<br><br>";
     
 }
 
}

Thanks for your effort!
I will make a donation to Drupal!

Webdesign
Weboldal Készítés Weboldal.biz