Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   non-western characters in links and JAVASCRIPT? (http://www.velocityreviews.com/forums/t922797-non-western-characters-in-links-and-javascript.html)

namemattersnot@msn.com 02-04-2006 05:07 PM

non-western characters in links and JAVASCRIPT?
 
re,

I have the following problem: links containinig cyrillic characters do
not display by the javascript.

server-side PHP script encodes them with rawurlecode() function and
everything works in Firefox , however, the encoded link does not work
in IE and only when trying to open it from within a javascript.

Here's the example: http://tmd.df.ru/test

Any ideas? :)


VK 02-04-2006 05:22 PM

Re: non-western characters in links and JAVASCRIPT?
 

namemattersnot@msn.com wrote:
> re,
>
> I have the following problem: links containinig cyrillic characters do
> not display by the javascript.
>
> server-side PHP script encodes them with rawurlecode() function and
> everything works in Firefox , however, the encoded link does not work
> in IE and only when trying to open it from within a javascript.
>
> Here's the example: http://tmd.df.ru/test
>
> Any ideas? :)


What encoding is set in Content-Type by your server?


namemattersnot@msn.com 02-04-2006 05:48 PM

Re: non-western characters in links and JAVASCRIPT?
 
honestly - i don't know. i've tested it on 3 different servers (one
located in Russia, 1 in the States, and one installed on my own box)
and regardless of the content-type that I specify in the <meta tag>,
the problem still persists.

i don't have a single other problem displaying links encoded in KOI8-R,
CP1251, etc.


Grard Talbot 02-04-2006 06:10 PM

Re: non-western characters in links and JAVASCRIPT?
 
namemattersnot@msn.com wrote :

1-
Re-edit your document so that <title> is inside the <head> part:

<!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="ru" lang="ru">

<head>

<meta http-equiv="Content-Type" content="text/html;
charset=windows-1251"></meta>
<meta http-equiv="Content-Language" content="ru"></meta>
<meta http-equiv="Content-Style-Type" content="text/css"></meta>

<title>test</title>

(...)

</head>

<body>

2-
If you are going to serve your document as text/html, then why do you
choose XHTML 1.0 strict? HTML 4.01 strict would do just fine.

3-
HTML 4.01 section B.2.1 Non-ASCII characters in URI attribute values
http://www.w3.org/TR/html401/appendi...on-ascii-chars

I would escape the non-ascii characters as suggested by the HTML 4.01
spec: "Escape these bytes with the URI escaping mechanism (i.e., by
converting each byte to %HH, where HH is the hexadecimal notation of the
byte value)."

Grard
--
remove blah to email me

VK 02-04-2006 06:32 PM

Re: non-western characters in links and JAVASCRIPT?
 

namemattersnot@msn.com wrote:
> honestly - i don't know. i've tested it on 3 different servers (one
> located in Russia, 1 in the States, and one installed on my own box)
> and regardless of the content-type that I specify in the <meta tag>,
> the problem still persists.
>
> i don't have a single other problem displaying links encoded in KOI8-R,
> CP1251, etc.


This works just fine (presuming paneuropean support is installed):

That should be the word "Russian" written in Russian through all
samples. Edit if jamed by newsreader. Also check that the declared
encoding corresponds to the *actual encoding used to type the text*
(thus to not bother with any other encoding issues: only the encoding
used to type the text and meta-content-type matching to that encoding).


<html>
<head>
<title>Russian</title>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1251">
<script type="text/javascript" charset="windows-1251">
function test(v) {
alert(v);
alert('*усский');
}
</script>
</head>

<body>

<p>
<a href="foo.html" onclick="test('*усский');return
false;">*усский</a>
</p>

</body>
</html>


namemattersnot@msn.com 02-04-2006 06:37 PM

Re: non-western characters in links and JAVASCRIPT?
 
Grard, thanks for the answer. this doesn't seem to be the
content-type problem nor my compliance with XHTML or HTML standards :)
just in case, i've modified the file as per your suggetion; alas, to no
avail.

non-ascii characters are escaped/converted using the PHP's
rawurlencode() function. as you can see.. it works without the
javascript in IE but doesn't when i pass the link to my script.

odd.


namemattersnot@msn.com 02-04-2006 06:43 PM

Re: non-western characters in links and JAVASCRIPT?
 
VK,

your little example works just fine. still.. i don't have an answer to
my original post :)

this has been bugging me a couple of days now.


VK 02-04-2006 07:08 PM

Re: non-western characters in links and JAVASCRIPT?
 

namemattersnot@msn.com wrote:
> VK,
>
> your little example works just fine. still.. i don't have an answer to
> my original post :)
>
> this has been bugging me a couple of days now.


Indicate the right charset in the page head and <script> (if needed).
If you want to have extra chars in the page text, use &...; form
If you want to have extra chars in your script use \uFFFF form

%FF form is *not* legal neither in HTML text nor in script. Do not
confuse it with urlencoded GET request. Bring your page into right form
and be happy ever after :-)


namemattersnot@msn.com 02-04-2006 07:24 PM

Re: non-western characters in links and JAVASCRIPT?
 
the right charset is already indicated in the head section. russian
characters, therefore, are properly displayed. why wouldn't links work?
how do i encode them then?


VK 02-04-2006 07:51 PM

Re: non-western characters in links and JAVASCRIPT?
 

namemattersnot@msn.com wrote:
> the right charset is already indicated in the head section. russian
> characters, therefore, are properly displayed. why wouldn't links work?
> how do i encode them then?


Again: %FF format is not valid neither in the HTML page nor within
<script> literals

This part:
<a href="test_%20%F0%F3%F1%F1%EA%E8%E9%201.gif">
is not valid.

Make sure that it's a plain Russian text in the encoding matching to
the declared Content-Type.



All times are GMT. The time now is 09:50 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.