Converting VBScript ChrB and AscB to JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Mark Bram

    Converting VBScript ChrB and AscB to JavaScript

    Hi All,

    I am trying to convert an ASP upload script from VBScript to JavaScript:


    I am stuck on this function:

    //String to byte string conversion
    function byte2String(sSt ring)
    {
    var result = new String();

    for (var index = 0; index < sString.length; index ++)
    {
    result += ChrB(AscB(Mid(s String,i,1)));
    } // end for

    return result;
    } // end function


    Obviously the line I am stuck on is:
    result += ChrB(AscB(Mid(s String,i,1)));
    Are there any IIS JavaScript equivalents for ChrB and AscB?

    Any help would be most appreciated!

    Rob
    :)


  • kaeli

    #2
    Re: Converting VBScript ChrB and AscB to JavaScript

    In article <411cc715$0$254 58$afc38c87@new s.optusnet.com. au>, "Robert Mark
    Bram" <none> enlightened us with...[color=blue]
    > Hi All,
    >
    >
    > Obviously the line I am stuck on is:
    > result += ChrB(AscB(Mid(s String,i,1)));
    > Are there any IIS JavaScript equivalents for ChrB and AscB?
    >[/color]

    I found this via google. Don't know if it works.
    ChrB(AscB(chr))
    JScript equivalent:
    chr.charCodeAt( 0) & 255;

    You'd have to use substring functions to replace the Mid.

    --
    --
    ~kaeli~
    I can't sleep.
    The clowns might eat me.



    Comment

    • Robert Mark Bram

      #3
      Re: Converting VBScript ChrB and AscB to JavaScript

      > I found this via google. Don't know if it works.[color=blue]
      > ChrB(AscB(chr))
      > JScript equivalent:
      > chr.charCodeAt( 0) & 255;[/color]

      Thank you Kaeli,

      Try not to be too afraid of the clowns.. :)

      Rob
      :)


      Comment

      Working...