-
January 1st, 2008, 01:17 PM
#1
charset problem?
Hey!
http://www.roscripts.com/Ajax_autosu...abase-154.html
I'm using this neat script for searching on my website.. but the thing is i have saved sentences with norwegian special charachters to my db, and when these are printed with this script the æ ø å's shows up like "?" instead. I am using charset=iso-8859-1 in the <head> tag
and charset=iso-8859-1 in the <script> tag
all other special characters show up as they should, its ONLY those who goes thru the search script that doesnt show up as they should.
I really hope someone understands my problem and could come with some input since i really want to use this on my site
-
January 1st, 2008, 01:35 PM
#2
Re: charset problem?
Those characters are part of the UTF-8 charset.
PHP is known to have some problems with multibyte characters, since 1 char in PHP is represented on 1 byte.
The solution is fairly simple: change the header and content type encoding to utf-8:
Code:
header('Content-Type: text/html; charset=utf-8');
...
and later:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
Hope this helps.
-
January 1st, 2008, 01:53 PM
#3
Re: charset problem?
Thanks for the reply!
When I did what you told me, the search part worked! I could search after special characters, and they showed up .. but all other special characters that is in my index.php suddenly went to "?".. how come? :S since they showed up when i used the iso88-59-1, they should show when i use the uft-8 too? i dont really understand why this happens?
-
January 1st, 2008, 02:02 PM
#4
Re: charset problem?
Maybe you added the header encoding too late and the browser assumed a default encoding.
Make sure that both header and content-type encodings apply to index.php.
-
January 1st, 2008, 02:09 PM
#5
Re: charset problem?
ok. it works now i just had to close the meta tag! with a "/>".
Thanks alot!
btw..
all data that has been written in my form and sent to my database while i used the iso 8xxx charset wont come turn up as special characters when i use utf-8 ?
-
January 1st, 2008, 02:13 PM
#6
Re: charset problem?
Depends on how it was saved in the db.
Anyway, if it turns out that the data wasn't saved OK, then modify all your forms and add this extra attribute, to make sure they will post utf-8 encoded data:
Code:
<form ... accept-charset="utf-8" ... >
...
</form>
-
January 1st, 2008, 02:17 PM
#7
Re: charset problem?
ok. seems like it wasnt saved as utf-8. I'll add that code to my forms just in case then thanks alot again, and happy new year!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|