A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Can you optimize this replace code?

  1. #1
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472

    Can you optimize this replace code?

    String.prototype.replace = function() {
    str = this
    str=str.split("Š").join("*");
    str=str.split("š").join("š");
    str=str.split("œ").join("œ");
    str=str.split("ž").join("ž");
    str=str.split("Ÿ").join("Ÿ");
    str=str.split("¢").join("¢");
    str=str.split("¥").join("¥");
    str=str.split("À").join("À");
    str=str.split("Á").join("Á");
    str=str.split("Â").join("Â");
    str=str.split("Ã").join("Ã");
    str=str.split("Ä").join("Ä");
    [about 200 more characters ... ]
    return str;
    }
    Don't ask me how we landed on this crappy solution ...
    If you have an idea on how to optimize the code at you will make a lot of poor processors very happy

    Regards
    POD
    Last edited by podenphant; 11-20-2003 at 11:26 AM.

  2. #2
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    Wow. Just to get a better idea of what you are after, what are you using this for?

    I think one can loop through all the unicode (i.e. \u0036) characters and replace them somehow, but I don't have my beloved book with all the codes in it. Are these unicode chars? Or am I confused...
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

  3. #3
    Bob (the singing sock)
    Join Date
    Aug 2000
    Location
    Århus, Denmark
    Posts
    472
    well ...

    The string is pulled from a database via ASP.
    The text-format in the DB cannot be send in an unchanged format to flash because the special characters are misread.

    I replace the special characters in ASP and reconvert them in flash.

    If i set the ASP codepage to 65001 the problem is solved. However this messes the rest of the site up because of the CMS in which the application runs.

    With the flash 7 player the problem is solved. But the client thinks it is to early for flash 7 - and so do I.

    The optimal solution would be if the charset could be converted in ASP without setting a codepage.

    Any thoughts are appreciated - it is this kind of problem that makes you wish you made a living sweaping floors .... NAAAAAHHH

    Regards pod

  4. #4
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    Well, what problems are in 7 that you are afraid of? I know you said the site would be messed up, but I think it would be better to change a few things (i think...er...hope) rather than type 220 lines of code that can be done easier with 7.
    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center