Thread: HELP!!!! UNICODE problem
Hello, I am using postgresql and PHP to develop an application supporting English/French/Arabic Data. I am using PHP5RC1 and Postgresql 7.4.2 When the user enters french caracters (é,è,...) I get the following error. ==================== Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid byte sequence for encoding "UNICODE": 0xe96d61 in /usr/local/apache2/htdocs/Classes/DBAdapter.class.php on line 27 ==================== I managed to save my SQL string into a file. When open with vi, the file reads ============== update classe set code='MATE',description='Mathématiques Elémentaires',cycle='SEC',classesuperieure=NULL,info=NULL where code='MATE' ~ ============== whereas the command cat shows ============== update classe set code='MATE',description='Math�matiques El�mentaires',cycle ='SEC',classesuperieure=NULL,info=NULL where code='MATE' ============== I tried to figure out what to do; when I copy and paste the content of the file into the "psql" tool, it works perfectly and I can see the accented letters in my browser; whereas the psql's command "\i <filename>" generates the same. Any help would be appreciated Regards Dani Mezher
> ============== > update classe set code='MATE',description='Math�matiques El�mentaires',cycle > ='SEC',classesuperieure=NULL,info=NULL where code='MATE' > ============== That's happening because you have not correctly specified the page encoding in the HTML page. So, Internet Explorer converts the entities badly... Chris
Hi, U could use urlencode if the method is get. Its its post, then there will be no problem. -vimala/. On Mon, 26 Apr 2004 fi94te02@fi.usj.edu.lb wrote: > Hello, > > I am using postgresql and PHP to develop an application supporting > English/French/Arabic Data. I am using PHP5RC1 and Postgresql 7.4.2 > > When the user enters french caracters (�,�,...) I get the following error. > > ==================== > > Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid > byte sequence for encoding "UNICODE": 0xe96d61 in > /usr/local/apache2/htdocs/Classes/DBAdapter.class.php on line 27 > ==================== > > I managed to save my SQL string into a file. When open with vi, the file reads > ============== > update classe set code='MATE',description='Math�matiques > El�mentaires',cycle='SEC',classesuperieure=NULL,info=NULL where code='MATE' > ~ > ============== > > whereas the command cat shows > > ============== > update classe set code='MATE',description='Math�matiques El�mentaires',cycle > ='SEC',classesuperieure=NULL,info=NULL where code='MATE' > ============== > > I tried to figure out what to do; when I copy and paste the content of the > file into the "psql" tool, it works perfectly and I can see the accented > letters in my browser; whereas the psql's command "\i <filename>" generates > the same. > > Any help would be appreciated > > Regards > Dani Mezher > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend >
I added the following line in the head section of my html <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Silly me... I forgot that the header in PHP was sent using the "header" function. When I set the charset to utf-8, it worked perfectly. Thanks Dani On Apr 27, 2004, at 10:54 AM, Dani Mezher wrote: > I added the following line in the head section of my html > > <DEFANGED_meta http-equiv="Content-Type" content="text/html; > charset=utf-8"> > but it still doesn't work. Actually, when I type arabic letters the > query executes but I get question marks instead of arabic text. French > characters > generate the error. > > I installed a previous web server on my Mac OSX and it works with > french/arabic/english without any kind of specification of the > document encoding. > > Regards > Dani > > On Apr 26, 2004, at 7:44 PM, Christopher Kings-Lynne wrote: > >> >>> ============== >>> update classe set code='MATE',description='MathA533;matiques >>> El�mentaires',cycle >>> ='SEC',classesuperieure=NULL,info=NULL where code='MATE' >>> ============== >> >> That's happening because you have not correctly specified the page >> encoding in the HTML page. So, Internet Explorer converts the >> entities badly... >> >> Chris >> >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 5: Have you checked our extensive FAQ? >> >> http://www.postgresql.org/docs/faqs/FAQ.html >> > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >