Created
August 4, 2016 16:18
-
-
Save nathanl/d7aed499f9be753f227d193a6357c3f2 to your computer and use it in GitHub Desktop.
Zalgo text maker
This file contains hidden or 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
defmodule Zalgo do | |
def this(string) do | |
String.graphemes(string) | |
|> Enum.map(fn (char) -> char <> the_funk end) | |
|> Enum.join | |
end | |
def the_funk do | |
accent_codes | |
|> Enum.map(fn (hex) -> | |
Integer.parse(hex, 16) |> elem(0) | |
end) | |
|> Enum.map(fn (int) -> | |
<< int :: utf8 >> | |
end) | |
|> Enum.join | |
end | |
def accent_codes do | |
# See more at http://unicode.org/charts/PDF/U0300.pdf | |
[ | |
"302", | |
"302", | |
"302", | |
"0348", | |
"0348", | |
"0348", | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment