www.webdeveloper.com
Results 1 to 6 of 6

Thread: Internationalizing JavaScript

  1. #1
    Join Date
    May 2005
    Posts
    208

    Internationalizing JavaScript

    does anybody know how to make international string in JavaScript?

    for instance:

    var temp = "international stuff goes here";

    when i try to redisplay this temp variable in html page to the user
    it shows ??????


    Thanks

  2. #2
    Join Date
    Jan 2004
    Posts
    484
    I believe that you are looking for a golbal var?

    as long as you declare the varible on the page out side of any function then you should be able to call it.

    or you can pass a varible "string" through the url: www.something.com/sompage.htm?var=some string

    you can also write your varible "string" to cookies.

    hopes this helps
    Natdrip :P
    "water go down the hole" - plucky duck

  3. #3
    Join Date
    May 2005
    Posts
    208
    Nope, actually consider this:

    Function foo()
    {
    Var temp = “german letters go here”;
    Document.getElementById(“myId”).innerHTML=”temp”;
    }

    After call to this function instead of seeing actual German letters I see ???????????

  4. #4
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    You need to change the character encoding for the page in the HTML.
    Stephen

  5. #5
    Join Date
    May 2005
    Posts
    208
    it is not an html page
    JS resides in .js file

  6. #6
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    Then you will need to save your JS file with a different character encoding (it should be an option when you save it in your text editor).
    You could also play it safe by first escaping all the text and putting the escaped version into in a string then using an additonal step in JS to unescape the string via decodeURI.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles