Created
May 12, 2014 16:52
-
-
Save anonymous/c6dff14fd6ce75dc9a35 to your computer and use it in GitHub Desktop.
strToCodes.coffee
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 == "d" # i.e. "\n" | |
pos++ | |
result.join(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment