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 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> References: <6485665e-6cf2-44b3-9641-6d5cd629c473@googlegroups.com> <87385bisue.fsf@bsb.me.uk> <8fdd532b-a5d9-41db-8f95-fd0975b2f77a@googlegroups.com> Reply-To: Thomas 'PointedEars' Lahn 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 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> 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: > 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: 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: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.