Skip to content

Instantly share code, notes, and snippets.



Last active Nov 23, 2020
What would you like to do?
func zalgo(_ string: String, intensity: Int = 5) -> String {
let combiningDiacriticMarks = 0x0300...0x036f
let latinAlphabetUppercase = 0x0041...0x005a
let latinAlphabetLowercase = 0x0061...0x007a
var output: [UnicodeScalar] = []
for scalar in string.unicodeScalars {
guard (latinAlphabetUppercase).contains(numericCast(scalar.value)) ||
else {
for _ in 0...(Int.random(in: 1...intensity)) {
let randomScalarValue = Int.random(in: combiningDiacriticMarks)
return String(String.UnicodeScalarView(output))

This comment has been minimized.

Copy link

@MatthiasLamoureux MatthiasLamoureux commented Oct 23, 2018

Hello @mattt,

Should not the latin uppercase and lowercase ranges be 0x0041...0x005a and 0x0061...0x007a ?


This comment has been minimized.

Copy link
Owner Author

@mattt mattt commented Nov 21, 2018

You're right, @MatthiasLamoureux — I'm not sure why I was using those ranges here. Thanks for pointing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.