Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > non-western characters in links and JAVASCRIPT?

Reply
Thread Tools

non-western characters in links and JAVASCRIPT?

 
 
namemattersnot@msn.com
Guest
Posts: n/a
 
      02-04-2006
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?

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      02-04-2006

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?

 
Reply With Quote
 
 
 
 
namemattersnot@msn.com
Guest
Posts: n/a
 
      02-04-2006
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.

 
Reply With Quote
 
Grard Talbot
Guest
Posts: n/a
 
      02-04-2006
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
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      02-04-2006

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>

 
Reply With Quote
 
namemattersnot@msn.com
Guest
Posts: n/a
 
      02-04-2006
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.

 
Reply With Quote
 
namemattersnot@msn.com
Guest
Posts: n/a
 
      02-04-2006
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.

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      02-04-2006

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

 
Reply With Quote
 
namemattersnot@msn.com
Guest
Posts: n/a
 
      02-04-2006
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?

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      02-04-2006

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python unicode utf-8 characters and MySQL unicode utf-8 characters Grzegorz liwiski Python 2 01-19-2011 07:31 AM
Remove only special characters and junk characters from a file rvino Perl 0 08-14-2007 07:23 AM
pointers to constant characters and constant pointers to characters sam_cit@yahoo.co.in C Programming 4 12-14-2006 11:10 PM
Adding a delimiter inbetween number characters and letter characters toomanyjoes@mail.utexas.edu Perl Misc 54 01-16-2005 04:07 PM
IE and links with scandinavian characters Kristian Niemi HTML 3 07-12-2004 07:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57