S
stevelooking41
Can someone explain why I don't seem unable to use document.write to
produce a valid UTF-8 none breaking space sequence (Hex: C2A0) ?
I've tried everyway I've been able to find to tell the browser I'm
trying to print UTF-8 and still no luck. I'd like the first 2 tries to
match the second two tries as far as output.
<HTML>
<meta http-equiv="Content-Type" content="application/x-script;
charset=UTF-8">
<SCRIPT language="javascript" charset="UTF-8">
var out = "UTF-8 nbsp:\xC2\xA0:Unicode:\uC2A0:Unicode:\u00A0:HTML
nbsp: "
document.open("text/html; charset=UTF-8");
document.write(out);
var i =0;
while (i <out.length){
document.write("<br>"+i+" "+out.charAt(i)+" "+out.charCodeAt(i));
i++;
}
document.close();document.charset="UTF-8";
</SCRIPT>
</HTML>
The output looks like this:
UTF-8 nbsp: :Unicode:ìŠ :Unicode: :HTML nbsp:
0 U 85
1 T 84
2 F 70
3 - 45
4 8 56
5 32
6 n 110
7 b 98
8 s 115
9 p 112
10 : 58
11 Â 194
12 160
13 : 58
14 U 85
15 n 110
16 i 105
17 c 99
18 o 111
19 d 100
20 e 101
21 : 58
22 ìŠ 49824
23 : 58
24 U 85
25 n 110
26 i 105
27 c 99
28 o 111
29 d 100
30 e 101
31 : 58
32 160
33 : 58
34 H 72
35 T 84
36 M 77
37 L 76
38 32
39 n 110
40 b 98
41 s 115
42 p 112
43 : 58
44 & 38
45 n 110
46 b 98
47 s 115
48 p 112
49 ; 59
Thanks!
produce a valid UTF-8 none breaking space sequence (Hex: C2A0) ?
I've tried everyway I've been able to find to tell the browser I'm
trying to print UTF-8 and still no luck. I'd like the first 2 tries to
match the second two tries as far as output.
<HTML>
<meta http-equiv="Content-Type" content="application/x-script;
charset=UTF-8">
<SCRIPT language="javascript" charset="UTF-8">
var out = "UTF-8 nbsp:\xC2\xA0:Unicode:\uC2A0:Unicode:\u00A0:HTML
nbsp: "
document.open("text/html; charset=UTF-8");
document.write(out);
var i =0;
while (i <out.length){
document.write("<br>"+i+" "+out.charAt(i)+" "+out.charCodeAt(i));
i++;
}
document.close();document.charset="UTF-8";
</SCRIPT>
</HTML>
The output looks like this:
UTF-8 nbsp: :Unicode:ìŠ :Unicode: :HTML nbsp:
0 U 85
1 T 84
2 F 70
3 - 45
4 8 56
5 32
6 n 110
7 b 98
8 s 115
9 p 112
10 : 58
11 Â 194
12 160
13 : 58
14 U 85
15 n 110
16 i 105
17 c 99
18 o 111
19 d 100
20 e 101
21 : 58
22 ìŠ 49824
23 : 58
24 U 85
25 n 110
26 i 105
27 c 99
28 o 111
29 d 100
30 e 101
31 : 58
32 160
33 : 58
34 H 72
35 T 84
36 M 77
37 L 76
38 32
39 n 110
40 b 98
41 s 115
42 p 112
43 : 58
44 & 38
45 n 110
46 b 98
47 s 115
48 p 112
49 ; 59
Thanks!