Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27017
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Xor characters in string do not work |
| Date | 2015-03-11 15:34 +0100 |
| Organization | Liberty Development |
| Message-ID | <mdpjpn$b2l$1@adenine.netfront.net> (permalink) |
| References | <6485665e-6cf2-44b3-9641-6d5cd629c473@googlegroups.com> <87385bisue.fsf@bsb.me.uk> <8fdd532b-a5d9-41db-8f95-fd0975b2f77a@googlegroups.com> |
jonas.thornvall@gmail.com wrote:
> Den onsdag 11 mars 2015 kl. 14:09:23 UTC+1 skrev Ben Bacarisse:
>> jonas.thornvall@gmail.com writes:
> Do i really need to loop with charCodeAt building up the string?
> Or is there better way
>
> for (i=0;i<key.length;i++) keyarr[i]=key.charCodeAt(i);
>
> This seem a bit primitive is there no other way to simply remap the characters from a full string into an array.
>
> Let me dream a little keyarr=key.charCodeStr()
> Voila it is done.
You can (at least in JavaScript) treat a string like an array and use
the "map" method:
var s = "abc";
var a = [].map.call(s, function(ch) { return ch.charCodeAt(); });
But of course strings are sequences of 16 bit Unicode characters not of
8 bit values.
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Xor characters in string do not work jonas.thornvall@gmail.com - 2015-03-11 04:44 -0700
Re: Xor characters in string do not work Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-03-11 13:09 +0000
Re: Xor characters in string do not work jonas.thornvall@gmail.com - 2015-03-11 06:49 -0700
Re: Xor characters in string do not work Martin Honnen <mahotrash@yahoo.de> - 2015-03-11 15:34 +0100
Re: Xor characters in string do not work Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-03-12 15:43 +0100
Re: Xor characters in string do not work Scott Sauyet <scott.sauyet@gmail.com> - 2015-03-11 07:52 -0700
csiph-web