GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Country and city names from dropdown selection - problem with language characters  XML
Forum Index -> FAQ - frequently asked questions
Author Message
ns1



Joined: 28/01/2011 11:21:15
Messages: 3
Offline

Hi,

I have imported your date into my database as instructed and all seems ok.
However, when i query the data to populate my drop down selection i get ? (question marks) instead of some characters specific for some languages like
š, č, đ, ž, etc.

Also, countries that have ' like Cote D'Ivory are causing me problems with javascript - probably in URL enoding is the problem..

I am not an php expert, so your help would be appreciated.

I have tried to insert this after my database connection, but no help.
Code:
mysql_set_charset('utf8_general_ci',$dbc);


this is sample code for querying the city database per selected country:
Code:
		
 $qc2="select * from all_cities where ccode='$ccode2' ORDER BY city ASC ";
 		$rc2=mysqli_query($dbc, $qc2);
 //		$rc2 = mb_convert_encoding($rc2, "UTF-8", "auto"); //konverzija stringa u UTF-8
 		$citys2=array();
 		while($row2=mysqli_fetch_array($rc2, MYSQLI_ASSOC))
 		{  
 				$ic=true;
 				foreach($citys2 as $k=>$value2)
 				{
 						if($value2==$row2['city'])
 						{
 								$ic=false;
 								break;
 						}
 				}
 				if($ic)
 				{
 						$citys2[]=$row2['city'];
 				}
 		}
 


BTW: congratulations on the great work you've done with this database
marc



Joined: 08/12/2005 07:39:47
Messages: 4412
Offline


dmb_convert_encoding($rc2, "UTF-8", "auto");
 

remove the conversion from auto and set the encoding of your html pages to utf8.



Marc

[WWW]
ns1



Joined: 28/01/2011 11:21:15
Messages: 3
Offline

Hi marc,

Thx for answering. My pages are set with UTF-8 encoding:

Code:
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
 


as for

Code:
dmb_convert_encoding($rc2, "UTF-8", "auto"); 


I have removed it (commented it) since when active, with or without "auto" my drop down is not working.

most of my tables are in latin1 and when i insert data in them with my language characters in mysql they look like this:
test šćčžđ 


however, when i query them and display them on my site they look like this:
test šćčžđ 
marc



Joined: 08/12/2005 07:39:47
Messages: 4412
Offline

Maybe it would be easier to convert everything to utf8. Having two different encodings in the same db is not easy to handle.
Or put the utf8 stuff in a separate db.

Marc

[WWW]
ns1



Joined: 28/01/2011 11:21:15
Messages: 3
Offline

Thx marc.

It seems easier to convert this database to latin1 since that is what is showing properly. Can I do that? And please some pointers.. I have tried in phpmyadmin with changing of collation and charset but that didn't do the trick.

Thank you
marc



Joined: 08/12/2005 07:39:47
Messages: 4412
Offline

utf8 supports more characters than latin1. For this reason you cannot convert from utf8 to latin1 without loosing some characters. A lot of characters in utf8 simply cannot be displayed in latin1.

I am not a mysql user. I would guess in order to convert the db from one encoding to the other you have to export the db to a text extract, convert the extracted file to the new encoding (using iconv for instance) and import it again in a different database.


Marc

[WWW]
 
Forum Index -> FAQ - frequently asked questions
Go to:   
Powered by JForum 2.1.5 © JForum Team