473,241 Members | 1,442 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,241 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 2746
*** 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 programacin 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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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
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...

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.