Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29431

Re: How do I convert the following to Uint8Array.

Newsgroups comp.lang.javascript
Date 2016-01-24 09:44 -0800
References <ce4bb039-aa19-4cbe-bb9b-8b8f004f8992@googlegroups.com>
Message-ID <964eaf69-5aa6-4d3a-abb3-4a31dc42dffc@googlegroups.com> (permalink)
Subject Re: How do I convert the following to Uint8Array.
From Robby Balona <robby@grab.co.za>

Show all headers | View raw


On Friday, January 22, 2016 at 1:52:47 PM UTC+2, Robby Balona wrote:
> Hi Guys
> 
> I am new to javascript. I have been trying to figure this out for a week now and because I don't know what I am talking about .. its hard to Google the right solution.
> 
> 
> I have a string "ab05d705" and I am trying to convert it to the following so I can add it to a Uint8Array. So how do I convert the string "ab05d705" to  
> 0xab,0x05,0xd7,0x05 to put into the following 
> var data = new Uint8Array([0xab,0x05,0xd7,0x05]);
> 
> 
> Any help would be so appreciated
> 
> Thank you 
> 
> Robby




Ben .. you are my hero ......I cannot thank you enough... This is what i ended up with in the end



var data = new Uint8Array(s.match(/../g).map(function (s) {
      return parseInt(s, 16);
    }));

You Rock Dude.. thank you again everyone

Back to comp.lang.javascript | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How do I convert the following to Uint8Array. Robby Balona <robby@grab.co.za> - 2016-01-22 03:52 -0800
  Re: How do I convert the following to Uint8Array. Stefan Weiss <krewecherl@gmail.com> - 2016-01-22 13:25 +0100
    Re: How do I convert the following to Uint8Array. Stefan Weiss <krewecherl@gmail.com> - 2016-01-22 13:32 +0100
      Re: How do I convert the following to Uint8Array. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-22 12:54 +0000
        Re: How do I convert the following to Uint8Array. Stefan Weiss <krewecherl@gmail.com> - 2016-01-22 14:22 +0100
  Re: How do I convert the following to Uint8Array. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-22 12:41 +0000
  Re: How do I convert the following to Uint8Array. Robby Balona <robby@grab.co.za> - 2016-01-23 00:51 -0800
    Re: How do I convert the following to Uint8Array. Stefan Weiss <krewecherl@gmail.com> - 2016-01-23 12:15 +0100
    Re: How do I convert the following to Uint8Array. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-23 11:17 +0000
  Re: How do I convert the following to Uint8Array. Robby Balona <robby@grab.co.za> - 2016-01-24 09:44 -0800

csiph-web