Created
January 13, 2016 19:02
-
-
Save erica/77001353d4ee1c65dac4 to your computer and use it in GitHub Desktop.
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
var count = 0 | |
let headranges: [Range<Int>] = [0x00A1...0x00A7, 0x00B0...0x00B1, 0x2016...0x2017, 0x2020...0x2027, 0x2030...0x203E, 0x2041...0x2053, 0x2055...0x205E, 0x2190...0x23FF, 0x2500...0x2775, 0x2794...0x2BFF, 0x2E00...0x2E7F, 0x3001...0x3003, 0x3008...0x3030] | |
let headchars = [0x00A9, 0x00AB, 0x00AC, 0x00AE, 0x00B6, 0x00BB, 0x00BF, 0x00D7, 0x00F7] | |
let charranges: [Range<Int>] = [0x0300...0x036F, 0x1DC0...0x1DFF, 0x20D0...0x20FF, 0xFE00...0xFE0F, 0xFE20...0xFE2F, 0xE0100...0xE01EF] | |
print("Operator Heads") | |
print("/ = - + ! * % < > & | ^ ~ ?") | |
for value in headchars { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
}; print("") | |
for range in headranges { | |
for value in range { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
count += 1; if count % 16 == 0 { print("") } | |
}; print("") | |
} | |
print("Operator Characters") | |
count = 0 | |
for range in charranges { | |
for value in range { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
count += 1; if count % 16 == 0 { print("") } | |
}; print("") | |
} | |
let idheadchars = [0x00A8, 0x00AA, 0x00AD, 0x00AF, 0x2054] | |
let idheadranges: [Range<Int>] = [0x00B2...0x00B5, 0x00B7...0x00BA, 0x00BC...0x00BE, 0x00C0...0x00D6, 0x00D8...0x00F6, 0x00F8...0x00FF, 0x0100...0x02FF, 0x0370...0x167F, 0x1681...0x180D, 0x180F...0x1DBF, 0x1E00...0x1FFF, 0x200B...0x200D, 0x202A...0x202E, 0x203F...0x2040, 0x2060...0x206F, 0x2070...0x20CF, 0x2100...0x218F, 0x2460...0x24FF, 0x2776...0x2793, 0x2C00...0x2DFF, 0x2E80...0x2FFF, 0x3004...0x3007, 0x3021...0x302F, 0x3031...0x303F, 0x3040...0xD7FF, 0xF900...0xFD3D, 0xFD40...0xFDCF, 0xFDF0...0xFE1F, 0xFE30...0xFE44, 0xFE47...0xFFFD, 0x10000...0x1FFFD, 0x20000...0x2FFFD, 0x30000...0x3FFFD, 0x40000...0x4FFFD, 0x50000...0x5FFFD, 0x60000...0x6FFFD, 0x70000...0x7FFFD, 0x80000...0x8FFFD, 0x90000...0x9FFFD, 0xA0000...0xAFFFD, 0xB0000...0xBFFFD, 0xC0000...0xCFFFD, 0xD0000...0xDFFFD, 0xE0000...0xEFFFD] | |
let idcharranges: [Range<Int>] = [0x0300...0x036F, 0x1DC0...0x1DFF, 0x20D0...0x20FF, 0xFE20...0xFE2F] | |
print("Identifier heads") | |
print("Upper- or lowercase letter A through Z") | |
for value in idheadchars { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
} | |
print("") | |
count = 0 | |
for range in idheadranges { | |
for value in range { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
count += 1; if count % 16 == 0 { print("") } | |
}; print("") | |
} | |
print("Identifier characters") | |
print("Digit 0 through 9") | |
count = 0 | |
for range in idcharranges { | |
for value in range { | |
print(String(UnicodeScalar(value)), terminator:" ") | |
count += 1; if count % 16 == 0 { print("") } | |
}; print("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good code!, now this is translated to Swift 3:
`import Foundation
var count = 0
let headranges: [ClosedRange] = [0x00A1...0x00A7, 0x00B0...0x00B1, 0x2016...0x2017, 0x2020...0x2027, 0x2030...0x203E, 0x2041...0x2053, 0x2055...0x205E, 0x2190...0x23FF, 0x2500...0x2775, 0x2794...0x2BFF, 0x2E00...0x2E7F, 0x3001...0x3003, 0x3008...0x3030]
let headchars = [0x00A9, 0x00AB, 0x00AC, 0x00AE, 0x00B6, 0x00BB, 0x00BF, 0x00D7, 0x00F7]
let charranges: [ClosedRange] = [0x0300...0x036F, 0x1DC0...0x1DFF, 0x20D0...0x20FF, 0xFE00...0xFE0F, 0xFE20...0xFE2F, 0xE0100...0xE01EF]
print("Operator Heads")
print("/ = - + ! * % < > & | ^ ~ ?")
for valor in headchars {
print(UnicodeScalar(valor)!, terminator: " ")
}; print("")
for range in headranges {
for valor in range.lowerBound...range.upperBound {
print(UnicodeScalar(valor)!, terminator: " ")
count += 1; if count % 40 == 0 { print("") }
}; print("")
}
print("Operator Characters")
count = 0
for range in charranges {
for value in range.lowerBound...range.upperBound {
print(UnicodeScalar(value)!, terminator:" ")
count += 1; if count % 40 == 0 { print("") }
}; print("")
}
let idheadchars = [0x00A8, 0x00AA, 0x00AD, 0x00AF, 0x2054]
let idheadranges: [ClosedRange] = [0x00B2...0x00B5, 0x00B7...0x00BA, 0x00BC...0x00BE, 0x00C0...0x00D6, 0x00D8...0x00F6, 0x00F8...0x00FF, 0x0100...0x02FF, 0x0370...0x167F, 0x1681...0x180D, 0x180F...0x1DBF, 0x1E00...0x1FFF, 0x200B...0x200D, 0x202A...0x202E, 0x203F...0x2040, 0x2060...0x206F, 0x2070...0x20CF, 0x2100...0x218F, 0x2460...0x24FF, 0x2776...0x2793, 0x2C00...0x2DFF, 0x2E80...0x2FFF, 0x3004...0x3007, 0x3021...0x302F, 0x3031...0x303F, 0x3040...0xD7FF, 0xF900...0xFD3D, 0xFD40...0xFDCF, 0xFDF0...0xFE1F, 0xFE30...0xFE44, 0xFE47...0xFFFD, 0x10000...0x1FFFD, 0x20000...0x2FFFD, 0x30000...0x3FFFD, 0x40000...0x4FFFD, 0x50000...0x5FFFD, 0x60000...0x6FFFD, 0x70000...0x7FFFD, 0x80000...0x8FFFD, 0x90000...0x9FFFD, 0xA0000...0xAFFFD, 0xB0000...0xBFFFD, 0xC0000...0xCFFFD, 0xD0000...0xDFFFD, 0xE0000...0xEFFFD]
let idcharranges: [ClosedRange] = [0x0300...0x036F, 0x1DC0...0x1DFF, 0x20D0...0x20FF, 0xFE20...0xFE2F]
print("Identifier heads")
print("Upper- or lowercase letter A through Z")
for value in idheadchars {
print(UnicodeScalar(value)!, terminator:" ")
}
print("")
count = 0
for range in idheadranges {
for value in range.lowerBound...range.upperBound {
print(UnicodeScalar(value)!, terminator:" ")
count += 1; if count % 40 == 0 { print("") }
}; print("")
}
print("Identifier characters")
print("Digit 0 through 9")
count = 0
for range in idcharranges {
for value in range.lowerBound...range.upperBound {
print(UnicodeScalar(value)!, terminator:" ")
count += 1; if count % 40 == 0 { print("") }
}; print("")
}`