-
-
Save tekwiz/42d13ef3b45f2d1e822d to your computer and use it in GitHub Desktop.
strToCodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strToCodes = (str) -> | |
result = new Array(str.length) | |
pos = 0 | |
while pos < str.length | |
c = str.charCodeAt(pos).toString(16) | |
result[pos] = if c.length % 2 == 1 then "x0"+c else "x"+c | |
result[pos] += "\n" if c == "a" # i.e. "\n" | |
pos++ | |
result.join(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function strToCodes(str) { | |
var c, pos = 0, result = new Array(str.length); | |
while (pos < str.length) { | |
c = str.charCodeAt(pos).toString(16); | |
result[pos] = c.length % 2 === 1 ? "x0" + c : "x" + c; | |
if (c === "a") { | |
result[pos] += "\n"; | |
} | |
pos++; | |
} | |
return result.join(' '); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment