Οι Ομάδες Google δεν υποστηρίζουν πλέον νέες αναρτήσεις ή εγγραφές στο Usenet. Το ιστορικό περιεχόμενο παραμένει ορατό.

HELP utf8 safari VS firefox

10 προβολές
Παράβλεψη και μετάβαση στο πρώτο μη αναγνωσμένο μήνυμα

twigster

μη αναγνωσμένη,
21 Αυγ 2006, 5:42:33 μ.μ.21/8/06
ως
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("é");

?>

Alvaro G. Vicario

μη αναγνωσμένη,
21 Αυγ 2006, 6:08:39 μ.μ.21/8/06
ως
*** 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
--

twigster

μη αναγνωσμένη,
21 Αυγ 2006, 6:22:42 μ.μ.21/8/06
ως
I still get "é" rather than "é" in my alert in safari... :(

even with

// action.php

Bart Van der Donck

μη αναγνωσμένη,
22 Αυγ 2006, 5:22:27 π.μ.22/8/06
ως
twigster 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).

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

Bart Van der Donck

μη αναγνωσμένη,
22 Αυγ 2006, 5:36:31 π.μ.22/8/06
ως
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

0 νέα μηνύματα