how can I transform a string to code ascii?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eduardo Hernandez

    how can I transform a string to code ascii?

    I need to transform a string into an array of integer numbers that
    correspond to the code ascii of each character.

    Thanks.
    Eduardo Hernández
  • DB McGee

    #2
    Re: how can I transform a string to code ascii?

    Hrm - I think your only solution might be to use a hash table that matches
    chars to ASCII codes then parse each string character by character doing a
    look-up for each one?

    "Eduardo Hernandez" <ehernandezg@12 3mail.cl> wrote in message
    news:ea757fb5.0 311031836.52681 c3e@posting.goo gle.com...[color=blue]
    > I need to transform a string into an array of integer numbers that
    > correspond to the code ascii of each character.
    >
    > Thanks.
    > Eduardo Hernández[/color]


    Comment

    • Lee

      #3
      Re: how can I transform a string to code ascii?

      Eduardo Hernandez said:[color=blue]
      >
      >I need to transform a string into an array of integer numbers that
      >correspond to the code ascii of each character.[/color]

      var str="antidisest ablishmentarian ism";
      var code=new Array(str.lengt h);
      for(var i=0;i<str.lengt h;i++){
      code[i]=str.charCodeAt (i);
      }


      charCodeAt() actually returns the Unicode value, but that's
      the same as ASCII for the first 128 values.

      Comment

      • Svend Ezaki Tofte (DIKU)

        #4
        Re: how can I transform a string to code ascii?

        On Tue, 3 Nov 2003, Lee wrote:[color=blue][color=green]
        > >I need to transform a string into an array of integer numbers that
        > >correspond to the code ascii of each character.[/color]
        >
        > var str="antidisest ablishmentarian ism";
        > var code=new Array(str.lengt h);
        > for(var i=0;i<str.lengt h;i++){
        > code[i]=str.charCodeAt (i);
        > }
        >
        >
        > charCodeAt() actually returns the Unicode value, but that's
        > the same as ASCII for the first 128 values.[/color]

        I've written a few usefull prototypes, that does this kinda stuff. Feel
        free to use :)



        Regards,
        Svend

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: how can I transform a string to code ascii?

          Lee wrote:
          [color=blue]
          > Eduardo Hernandez said:[color=green]
          >>I need to transform a string into an array of integer numbers that
          >>correspond to the code ascii of each character.[/color]
          >
          > var str="antidisest ablishmentarian ism";
          > var code=new Array(str.lengt h);
          > for(var i=0;i<str.lengt h;i++){
          > code[i]=str.charCodeAt (i);
          > }[/color]

          var code = str.split("");
          for (var i = 0; i < code.length; i++)
          code[i] = code[i].charCodeAt(0);


          PointedEars

          Comment

          Working...