We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4b349ff commit 72b0d35Copy full SHA for 72b0d35
functions/strings/hex2bin.js
@@ -0,0 +1,18 @@
1
+function hex2bin(s) {
2
+ // discuss at: http://phpjs.org/functions/hex2bin/
3
+ // original by: Dumitru Uzun (http://duzun.me)
4
+ // example 1: bin2hex('44696d61');
5
+ // returns 1: 'Dima'
6
+ // example 2: bin2hex('00');
7
+ // returns 2: '\x00'
8
+
9
+ var ret = [], i = 0, l;
10
11
+ s += '';
12
13
+ for ( l s.length ; i < l; i+=2 ) {
14
+ ret.push(parseInt(s.substr(i, 2), 16));
15
+ }
16
17
+ return String.fromCharCode.apply(String, ret);
18
+}
0 commit comments