non-western characters in links and JAVASCRIPT?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • namemattersnot@msn.com

    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

    #2
    Re: non-western characters in links and JAVASCRIPT?


    namemattersnot@ msn.com wrote:[color=blue]
    > 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? :)[/color]

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

    Comment

    • namemattersnot@msn.com

      #3
      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.

      Comment

      • Gérard Talbot

        #4
        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


        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)."

        Gérard
        --
        remove blah to email me

        Comment

        • VK

          #5
          Re: non-western characters in links and JAVASCRIPT?


          namemattersnot@ msn.com wrote:[color=blue]
          > 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.[/color]

          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>Russia n</title>
          <meta http-equiv="Content-Type"
          content="text/html; charset=windows-1251">
          <script type="text/javascript" charset="window s-1251">
          function test(v) {
          alert(v);
          alert('Русский');
          }
          </script>
          </head>

          <body>

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

          </body>
          </html>

          Comment

          • namemattersnot@msn.com

            #6
            Re: non-western characters in links and JAVASCRIPT?

            Gérard, 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.

            Comment

            • namemattersnot@msn.com

              #7
              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.

              Comment

              • VK

                #8
                Re: non-western characters in links and JAVASCRIPT?


                namemattersnot@ msn.com wrote:[color=blue]
                > 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.[/color]

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

                Comment

                • namemattersnot@msn.com

                  #9
                  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?

                  Comment

                  • VK

                    #10
                    Re: non-western characters in links and JAVASCRIPT?


                    namemattersnot@ msn.com wrote:[color=blue]
                    > 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?[/color]

                    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.

                    Comment

                    • namemattersnot@msn.com

                      #11
                      Re: non-western characters in links and JAVASCRIPT?

                      but you can see the first link. encoding matches. characters are
                      properly displayed, yet IE does not want to open that link at all:


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

                      Comment

                      • Gérard Talbot

                        #12
                        Re: non-western characters in links and JAVASCRIPT?

                        namemattersnot@ msn.com wrote :[color=blue]
                        > Gérard, 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.
                        >[/color]

                        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.
                        [color=blue]
                        > 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.
                        >[/color]

                        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.

                        Gérard
                        --
                        remove blah to email me

                        Comment

                        • namemattersnot@msn.com

                          #13
                          Re: non-western characters in links and JAVASCRIPT?

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

                          Comment

                          • Ge'rard Talbot

                            #14
                            Re: non-western characters in links and JAVASCRIPT?

                            namemattersnot@ msn.com wrote :[color=blue]
                            > Javascript makes some neat effect with the picture. take a look in
                            > Firefox.[/color]

                            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.

                            [color=blue]
                            > 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 :)[/color]

                            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

                            Comment

                            • Ge'rard Talbot

                              #15
                              Re: non-western characters in links and JAVASCRIPT?

                              namemattersnot@ msn.com wrote :[color=blue]
                              > Javascript makes some neat effect with the picture. take a look in
                              > Firefox.[/color]

                              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?

                              [color=blue]
                              > 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 :)[/color]

                              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

                              Comment

                              Working...