473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

HELP utf8 safari VS firefox

Hi,

I've a pb with utf8 encoding with safari or firefox.

I retrieve the response of a XMLHttpRequest and depending if I use
safari or firefox I can't manage to get characters like "éàç"

to see an illustration you can try the code below :
(with this code I get a "é" with firefox but not with safari. I need to
add a ut8_decode to get the "é"!)
RQ : the files are encoded in utf8

thank you

// index.php :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>untitled</title>

</head>

<body>

<script type="text/javascript" charset="utf-8">

function search() {
var xmlHttp;
if (window.ActiveXObject) xmlHttp = new
ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest();
else { alert('JavaScript error : problem with
XMLHttpRequest objects ...'); return;}
var url = "action.php";
xmlHttp.open("GET", url, false);
xmlHttp.send(null);
if (xmlHttp.readyState == 4) { print(xmlHttp.responseText) }
}

function print (response) {
alert(response);
}

search();

</script>
</body>
</html>

-----------------------------------------------------
// action.php

<?php

echo "é";
// or
//echo ut8_decode("é");

?>

Aug 21 '06 #1
4 2749
*** twigster escribió/wrote (Mon, 21 Aug 2006 23:42:33 +0200):
// action.php

<?php

echo "é";
// or
//echo ut8_decode("é");

?>
I don't know if browsers obey HTTP headers under this situation, but it's
always good practice to make sure you have a correct Content-Type header.
If web server doesn't generate the correct one, do it yourself:

<?php

header('Content-Type: text/html; charset=UTF-8');

echo "é";

?>

.... given than you save the file as UTF-8 (all good editors allow you to
choose).
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Aug 21 '06 #2
I still get "é" rather than "é" in my alert in safari... :(

even with

// action.php

<?php

header('Content-Type: text/html; charset=UTF-8');

echo "é";

?>
Aug 21 '06 #3
twigster wrote:
I still get "é" rather than "é" in my alert in safari... :(
even with

// action.php
<?php
header('Content-Type: text/html; charset=UTF-8');
echo "é";
?>
I'ld say that the output stream should be correct when it shows 'é';
I think it's rather the browser that doesn't know how to represent the
offered data. A route from 'é' to 'é' uses a UTF-8 code table for
sure; since it corresponds to hex C3 ('Ã') plus hex A9 ('©'),
together forming Unicode's "LATIN SMALL LETTER E WITH ACUTE" ('é' or
hex E9 in "traditional" sets).

More info, search for 'C3A9' on:
http://home.tiscali.nl/t876506/utf8tbl.html

For the basic values, see table on
http://en.wikipedia.org/wiki/ISO_8859-1

Did you save action.php in UTF-8 mode ?

I'ld suggest to add meta-information in your page header as well:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

--
Bart

Aug 22 '06 #4
Bart Van der Donck wrote:
I'ld say that the output stream should be correct when it shows 'é';
I think it's rather the browser that doesn't know how to represent the
offered data. A route from 'é§*to 'é' uses a UTF-8 code table for
sure; since it corresponds to hex C3 ('ç) plus hex A9 ('?'),
together forming Unicode's "LATIN SMALL LETTER E WITH ACUTE" ('é§*or
hex E9 in "traditional" sets). [...]
It appears that at least Google Groups doesn't show these chars as they
were intended (which indicates again how messy character encoding in
browsers can be).

My post in GIF format:
http://www.dotinternet.be/temp/code.gif

--
Bart

Aug 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Christine Forber | last post by:
How can you make a div visible and hidden in safari? document.all.style.display = "none"; Does not appear to work. Also, can anyone tell me how to turn on javascript error commenting in...
5
by: Bill Cohagan | last post by:
I'm having some serious difficulties with my ASP.Net 2.0 app rendering in Safari 2.0.3. The most immediate problem is that the menu control doesn't seem to work at all, particularly the use of...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
3
by: Jeff Paffett | last post by:
I'm trying to use the onPaste event in a text input, which according to Apple is supported. However, I get no response in Safari. Firefox works fine.
7
by: Dayo | last post by:
Hello folks. Sorry if this seems a bit silly, I have no experience with this type of code. Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not...
20
by: weheh | last post by:
Dear web gods: After much, much, much struggle with unicode, many an hour reading all the examples online, coding them, testing them, ripping them apart and putting them back together, I am...
6
by: raknin | last post by:
I am creating a dynamic list on the server using php file,when I run the PHP script in all 4 browsers (IE 6, Firefox 2, opera and safari 3) every think go Ok and the list is created. but when I call...
3
by: Brad | last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and response.binarywrite to send content to the browser. This has worked great for years...
15
by: GinnTech | last post by:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. Here is the issue. I am attempting to call functions within a flash object. When trying to attempt to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.