javascript, window.open, mailto and cyrillic texts...

Discussion in 'Javascript' started by John, Oct 29, 2009.

  1. John

    John Guest

    Hi all,

    actually I am facing a problem when open an email client with
    window.open and cyrillic texts:

    The situation:

    function testMailTo() {
    var subj = escape("some subject text in cyrillic");
    var bod = escape("some body text in cyrillic");
    window.open( 'mailto:?subject='+subj
    +'&body='+bod);
    }

    The text gets translated dynamically at server side. It works perfect
    for French, German, Croatian, Czech and English. But as soon as I try
    Cyrillic, the email client shows something like:

    %u043D%u0456%u0442%u044C %u043D%u0430%u0441%u0442%u0443%u043F%u043D
    %u0435 %u043F%u043E%u0441%u0438%u043B%u0430%u043D%u043D

    for both the subject and the body text.

    I absolutly have no idea what to do. Does anybody has an idea?

    Thanks in advance
    John
     
    John, Oct 29, 2009
    #1
    1. Advertising

  2. John wrote:

    > actually I am facing a problem when open an email client with
    > window.open and cyrillic texts:
    >
    > The situation:
    >
    > function testMailTo() {
    > var subj = escape("some subject text in cyrillic");
    > var bod = escape("some body text in cyrillic");
    > window.open( 'mailto:?subject='+subj
    > +'&body='+bod);


    Use encodeURIComponent() instead of escape().

    Do not use window.open() with `mailto:'; use `window.location' instead.
    Users with browsers supporting tabbed browsing (the majority) will be
    grateful.

    Do not use `mailto:' URIs; use a server-side form-mailer instead.
    Webmail-only and Internet café users, among others, will be grateful.

    > the email client shows something like:
    >
    > %u043D%u0456%u0442%u044C %u043D%u0430%u0441%u0442%u0443%u043F%u043D
    > %u0435 %u043F%u043E%u0441%u0438%u043B%u0430%u043D%u043D
    >
    > for both the subject and the body text.


    Suppose the Cyrillic text used Unicode characters with code point beyond
    U+00FF, that would implement the suggestion in Appendix B.2.1 of the
    ECMAScript Language Specification (ECMA-262), Edition 3 Final, for the
    proprietary escape() method where it says:

    | [...]
    | 6. Get the character (represented as a 16-bit unsigned integer) at
    | position k within Result(1).
    | 7. If Result(6) is one of the 69 nonblank characters
    |
    “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./â€
    | then go to step 13.
    | 8. If Result(6), is less than 256, go to step 11.
    | 9. Let S be a string containing six characters “%uwxyz†where wxyz are
    | four hexadecimal digits encoding the value of Result(6).
    | 10. Go to step 14.
    | [...]

    > I absolutly have no idea what to do. Does anybody has an idea?


    ECMA-262-3 has been published and its encodeURIComponent() method has been
    implemented first approximately 9 years(!) ago (with JavaScript 1.5 in
    Netscape 6, Phoenix [Firefox precursor]; JScript 5.5 in IE 5.5 and Windows
    Me). RTFM (and dump the book in the likely case that your knowledge stems
    from there).

    <http://jibbering.com/faq/#posting>


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
     
    Thomas 'PointedEars' Lahn, Oct 29, 2009
    #2
    1. Advertising

  3. In comp.lang.javascript message <>,
    Thu, 29 Oct 2009 12:50:45, Thomas 'PointedEars' Lahn
    <> posted:

    >Do not use `mailto:' URIs; use a server-side form-mailer instead.
    >Webmail-only and Internet café users, among others, will be grateful.


    WRONG. It could read :

    If possible, do not offer only `mailto:' URIs; also offer a server-side
    form-mailer.

    Webmail-only and Internet café users, among others, will be grateful
    for the form mailer. Users of well-configured systems can also use
    `mailto:' URIs, and may prefer to do so.



    A good way of causing annoyance is to use a form-mailer with a default
    size textarea to type in.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
     
    Dr J R Stockton, Oct 29, 2009
    #3
  4. Dr J R Stockton wrote:

    > Thomas 'PointedEars' Lahn posted:
    >> Do not use `mailto:' URIs; use a server-side form-mailer instead.
    >> Webmail-only and Internet café users, among others, will be grateful.

    >
    > WRONG. [...]


    A less presumptuous poster would have written "IBTD" and the like.
    Because it is a matter of opinion (and target user group), not of
    right or wrong.


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Oct 30, 2009
    #4
  5. In comp.lang.javascript message <>,
    Fri, 30 Oct 2009 20:46:54, Thomas 'PointedEars' Lahn
    <> posted:
    >Dr J R Stockton wrote:
    >
    >> Thomas 'PointedEars' Lahn posted:
    >>> Do not use `mailto:' URIs; use a server-side form-mailer instead.
    >>> Webmail-only and Internet café users, among others, will be grateful.

    >>
    >> WRONG. [...]

    >
    >A less presumptuous poster would have written "IBTD" and the like.
    >Because it is a matter of opinion (and target user group), not of
    >right or wrong.


    TWIT. Except on an intranet, or on pages addressed only to a similarly
    limited readership, the target user group will be diverse in its
    circumstances, particularly but not only in the software that it has
    available and/or prefers.

    Rejecting provision of the convenient "mailto:" is the act of a control
    freak. Rejecting provision of "form-mail", where supportable, would
    also be the act of a control freak. Providing both matches the spirit,
    if not the exact circumstances, of Postel's Law (as at, for example,
    <http://en.wikipedia.org/wiki/Postel%27s_Law>).

    KETFOB.

    BTW, I forgot to mention that there was no mention of acronyms in the
    sig of that article of mine in which you falsely saw one. That should
    have been a clue.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
     
    Dr J R Stockton, Oct 30, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. phasma
    Replies:
    5
    Views:
    880
    Fredrik Lundh
    Sep 5, 2008
  2. rs387
    Replies:
    3
    Views:
    299
    pataphor
    Sep 14, 2008
  3. mike bayliss

    cyrillic and cdonts

    mike bayliss, May 28, 2004, in forum: ASP General
    Replies:
    1
    Views:
    188
    Egbert Nierop \(MVP for IIS\)
    May 28, 2004
  4. Nikolay Khodyunya

    win32 ruby1.9 regexp and cyrillic string

    Nikolay Khodyunya, Apr 27, 2010, in forum: Ruby
    Replies:
    3
    Views:
    243
    Caleb Clausen
    Apr 28, 2010
  5. Thomas Gagne
    Replies:
    2
    Views:
    358
    Robert Klemme
    Mar 15, 2013
Loading...

Share This Page