Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27020
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Xor characters in string do not work |
| Date | Thu, 12 Mar 2015 15:43:31 +0100 |
| Organization | PointedEars Software (PES) |
| Lines | 56 |
| Message-ID | <3767006.WovHSH5Fpe@PointedEars.de> (permalink) |
| References | <6485665e-6cf2-44b3-9641-6d5cd629c473@googlegroups.com> <87385bisue.fsf@bsb.me.uk> <8fdd532b-a5d9-41db-8f95-fd0975b2f77a@googlegroups.com> <mdpjpn$b2l$1@adenine.netfront.net> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1426171503 18193 eJwNyMEBwCAIA8CVEEig4wjK/iPYex6Mix1O0DGY8qMqyFmlYZ/mP+K7nZ2hxaZcyJm6zF62HxArEPY= (12 Mar 2015 14:45:03 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Thu, 12 Mar 2015 14:45:03 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwNy8EBwCAIA8CVpEKg4yAm+4/Q3v9iwzDpCHgoxIuachYkzUsga6Nha4fWiVjHvJtd6ZQeI7P73n/qaPgBbDkXKA== |
| Cancel-Lock | sha1:sdf3kmpjq3xppxOFKdq3MvATq6Y= |
| X-NNTP-Posting-Host | eJwFwYEBwCAIA7CXQNsyzhEc/59gwi1XB0SBw0H+tlwV4xWcL8voSDXIbUjrg0NfN3Ud6AcB7hAP |
| Xref | csiph.com comp.lang.javascript:27020 |
Show key headers only | View raw
Martin Honnen wrote:
> jonas.thornvall@gmail.com wrote:
>> 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);
More efficient “for” loops are written this way:
for (var i = 0, len = key.length; i < len; ++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:
Array.prototype.map() is supported by several implementations of ECMAScript
Ed. 5 and later:
<http://PointedEars.de/es-matrix/?filter=map>
> var s = "abc";
> var a = [].map.call(s, function(ch) { return ch.charCodeAt(); });
or
var a = s.split("").map(function (ch) { return ch.charCodeAt(); });
> But of course strings are sequences of 16 bit Unicode characters not of
> 8 bit values.
No, String values are, unfortunately, defined in ECMAScript (up to including
the 5.1 Edition) as “sequences of 16-bit units” only. Therefore, the built-
in String properties do not work for Unicode characters beyond the Basic
Multilingual Plane (BMP).
Remedy:
<http://PointedEars.de/wsvn/JSX/trunk/string/unicode.js> and the like.
> --- news://freenews.netfront.net/ - complaints: news@netfront.net ---
Eeek. Must you use *that*? It is a known source of trolls.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
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