473,386 Members | 1,958 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,386 software developers and data experts.

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? :)

Feb 4 '06 #1
16 2239
VK

na************@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?

Feb 4 '06 #2
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.

Feb 4 '06 #3
na************@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
Feb 4 '06 #4
VK

na************@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>

Feb 4 '06 #5
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.

Feb 4 '06 #6
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.

Feb 4 '06 #7
VK

na************@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 :-)

Feb 4 '06 #8
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?

Feb 4 '06 #9
VK

na************@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.

Feb 4 '06 #10
but you can see the first link. encoding matches. characters are
properly displayed, yet IE does not want to open that link at all:
http://tmd.df.ru/test/test_%20русский%201.gif

only: http://tmd.df.ru/test/test_%20%F0%F3...%E8%E9%201.gif

Feb 4 '06 #11
na************@msn.com wrote :
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.

Well, this should always be your first step whenever a page has some
problem: validate the markup and CSS code, then the problem gets easier
to figure out as you're eliminating a potential source of the problem
otherwise the problem often disappears.
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.


You do not need that rawurlencode function. You can escape the href
value while not escaping the anchor node.

Maybe I misunderstand your problem. I still don't see why you need
javascript in there.

Grard
--
remove blah to email me
Feb 4 '06 #12
Javascript makes some neat effect with the picture. take a look in
Firefox.

in any case, i am grateful for all of your comments. thank you! I will
take a look at it in a couple of days -- too annoyed at the moment :)

Feb 4 '06 #13
na************@msn.com wrote :
Javascript makes some neat effect with the picture. take a look in
Firefox.
What has the visual effect on the image to do with non-ascii characters
in the href value? This is what I do not understand.

in any case, i am grateful for all of your comments. thank you! I will
take a look at it in a couple of days -- too annoyed at the moment :)


This is how I would code your link:

<a href="test_%20%F0%F3%F1%F1%EA%E8%E9%201.gif">test_ ?o'n~n~e^e`e' 1.gif</a>

and this is what browsers like Mozilla and Firefox do: they
convert/escape accordingly non-ascii characters the way indicated in
section B.2.1

This post was windows-1251 encoded.

Gerard
--
remove blah to email me
Feb 5 '06 #14
na************@msn.com wrote :
Javascript makes some neat effect with the picture. take a look in
Firefox.
What has the visual effect on the image to do with non-ascii characters
in the href value? This is what I do not understand. What has the visual
effect on the image to do with the non-ascii characters?

in any case, i am grateful for all of your comments. thank you! I will
take a look at it in a couple of days -- too annoyed at the moment :)


This is how I would code your link:

<a href="test_%20%F0%F3%F1%F1%EA%E8%E9%201.gif">test_ ?o'n~n~e^e`e' 1.gif</a>

and this is what browsers like Mozilla and Firefox do: they
convert/escape accordingly non-ascii characters the way indicated in
section B.2.1 In the above example, you do it for MSIE 6+.

This post was windows-1251 encoded.

Gerard
--
remove blah to email me
Feb 5 '06 #15
na************@msn.com wrote:
^^^^^^^^^^^^^^
Well, it matters to me.
the right charset is already indicated in the head section. ^^^^^^^
What matters is if the same _encoding_ is declared with the `charset' label
of the `Content-Type' HTTP header because that takes precedence over any

<meta http-equiv="Content-Type" content="...; charset=...">

in the (X)HTML source code if the resource is served via HTTP.
See RFC1945 [1], 3.6.1, and RFC2616 [2], section 3.4.1. Use services like
<URL:http://web-sniffer.net/> and <URL:http://livehttpheaders.mozdev.org/>
to find out.
russian characters, therefore, are properly displayed.
Maybe. Maybe not.
why wouldn't links work? how do i encode them then?


You do not encode (visual hyper)links [3], you encode their target URIs as
described in RFC3986 [4], and, after that, as described in HTML 4.01 [5].
This has nothing to do with J(ava)Script/ECMAScript, though. [6]
PointedEars
___________
[1] <URL:http://www.rfc-editor.org/rfc/rfc1945.txt>
[2] <URL:http://www.rfc-editor.org/rfc/rfc2616.txt>
[3] <URL:http://www.rfc-editor.org/rfc/rfc3986.txt>
[4] <URL:http://www.w3.org/TR/html4/struct/links.html>
[5] <URL:http://www.w3.org/TR/html4/struct/links.html#h-12.2>
<URL:http://www.w3.org/TR/html4/types.html#h-6.4>
<URL:http://www.w3.org/TR/html4/appendix/notes.html#non-ascii-chars>
[6] <URL:http://validator.w3.org/>
Feb 16 '06 #16
na************@msn.com wrote:
but you can see the first link. encoding matches. characters are
properly displayed, yet IE does not want to open that link at all:
http://tmd.df.ru/test/test_%20???????%201.gif

only: http://tmd.df.ru/test/test_%20%F0%F3...%E8%E9%201.gif


Because the former is no URI. Read RFC3986.
PointedEars
Feb 16 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.