swift 一个更好的Swift NSRange

一个更好的Swift NSRange

NSRange.swift
// Playground - noun: a place where people can play

import Cocoa

extension NSRange {

    init(location:Int, length:Int) {
        self.location = location
        self.length = length
    }

    init(_ location:Int, _ length:Int) {
        self.location = location
        self.length = length
    }

    init(range:Range <Int>) {
        self.location = range.startIndex
        self.length = range.endIndex - range.startIndex
    }

    init(_ range:Range <Int>) {
        self.location = range.startIndex
        self.length = range.endIndex - range.startIndex
    }

    var startIndex:Int { get { return location } }
    var endIndex:Int { get { return location + length } }
    var asRange:Range<Int> { get { return location..<location + length } }
    var isEmpty:Bool { get { return length == 0 } }

    func contains(index:Int) -> Bool {
        return index >= location && index < endIndex
    }
    
    func clamp(index:Int) -> Int {
        return max(self.startIndex, min(self.endIndex - 1, index))
    }
    
    func intersects(range:NSRange) -> Bool {
        return NSIntersectionRange(self, range).isEmpty == false
    }

    func intersection(range:NSRange) -> NSRange {
        return NSIntersectionRange(self, range)        
    }
    
    func union(range:NSRange) -> NSRange {
        return NSUnionRange(self, range)
    }
    
}

NSRange(0, 10).clamp(10)
NSRange(0, 10).contains(10)


swift 在Xcode 6 GM + iOS 7.1中修复UICollectionViewCell损坏的自动布局约束

在Xcode 6 GM + iOS 7.1中修复UICollectionViewCell损坏的自动布局约束

BaseCollectionViewCell.swift
//
// Created by James Tang @jamztang
// https://gist.github.com/jamztang/68c3e16d071a01db81cf
//
// Credit goes to https://stackoverflow.com/questions/25753373/ios-8-gm-does-not-update-constraints-on-collection-views/25768375#25768375
//

import UIKit

class BaseCollectionViewCell: UICollectionViewCell {

    override var bounds : CGRect {
        didSet {
            // Fix autolayout constraints broken in Xcode 6 GM + iOS 7.1
            self.contentView.frame = bounds
        }
    }

}

swift 简单的Swift Debouncer

简单的Swift Debouncer

debounce.swift
func debounce( delay:NSTimeInterval, #queue:dispatch_queue_t, action: (()->()) ) -> ()->() {
	
	var lastFireTime:dispatch_time_t = 0
	let dispatchDelay = Int64(delay * Double(NSEC_PER_SEC))
	
	return {
		lastFireTime = dispatch_time(DISPATCH_TIME_NOW,0)
		dispatch_after(
			dispatch_time(
				DISPATCH_TIME_NOW,
				dispatchDelay
			),
			queue) {
				let now = dispatch_time(DISPATCH_TIME_NOW,0)
				let when = dispatch_time(lastFireTime, dispatchDelay)
				if now >= when {
					action()
				}
			}
	}
}

swift 斯威夫特的可可伐木工人可以轻松地工作。

斯威夫特的可可伐木工人可以轻松地工作。

Readme.md
# CocoaLumberjack.swift

## Prerequisites

*This assumes you have the CocoaLumberjack pod in your Podfile (tested with 2.0.0-beta)*  
*Also import `CocoaLumberjack/DDLog.h` and `CocoaLumberjack/DDTTYLogger.h` in your bridging header*

## Configuring the loggin

- As usual add all the loggers you might want/need: `DDLog.addLogger(DDTTYLogger.sharedInstance())`
- Configure the log level like so: `DDLog.logLevel = .Info`
- Log away :)
- You might also want to enable/disable async logging: `DDLog.logAsync = false`

## License

This Gist is under MIT
CocoaLumberjack.swift
//  Created by Ullrich Schäfer on 16/08/14.


// Bitmasks are a bit tricky in swift
// See http://natecook.com/blog/2014/07/swift-options-bitmask-generator/

//enum LogFlag: Int32 {
//    case Error   = 0b1
//    case Warn    = 0b10
//    case Info    = 0b100
//    case Debug   = 0b1000
//    case Verbose = 0b10000
//}

struct LogFlag : RawOptionSetType {
    private var value: Int32 = 0
    init(_ value: Int32) { self.value = value }
    var boolValue: Bool { return self.value != 0 }
    func toRaw() -> Int32 { return self.value }
    static func fromRaw(raw: Int32) -> LogFlag? { return self(raw) }
    static func fromMask(raw: Int32) -> LogFlag { return self(raw) }
    static func convertFromNilLiteral() -> LogFlag { return self(0) }
    
    static var Error:   LogFlag { return self(1 << 0) }
    static var Warn:    LogFlag { return self(1 << 1) }
    static var Info:    LogFlag { return self(1 << 2) }
    static var Debug:   LogFlag { return self(1 << 3) }
    static var Verbose: LogFlag { return self(1 << 4) }
}
func == (lhs: LogFlag, rhs: LogFlag) -> Bool { return lhs.value == rhs.value }



//enum LogLevel: Int32 {
//    case Off     = 0b0
//    case Error   = 0b1
//    case Warn    = 0b11
//    case Info    = 0b111
//    case Debug   = 0b1111
//    case Verbose = 0b11111
//    case All     = 0bFFFFFFFF // 1111....11111 (LOG_LEVEL_VERBOSE plus any other flags)
//}

struct LogLevel : RawOptionSetType {
    private var value: Int32 = 0
    init(_ value: Int32) { self.value = value }
    var boolValue: Bool { return self.value != 0 }
    func toRaw() -> Int32 { return self.value }
    static func fromRaw(raw: Int32) -> LogLevel? { return self(raw) }
    static func fromMask(raw: Int32) -> LogLevel { return self(raw) }
    static func convertFromNilLiteral() -> LogLevel { return self(0) }
    
    static var Off:     LogLevel { return self(0b0) }
    static var Error:   LogLevel { return self(0b1) }
    static var Warn:    LogLevel { return self(0b11) }
    static var Info:    LogLevel { return self(0b111) }
    static var Debug:   LogLevel { return self(0b1111) }
    static var Verbose: LogLevel { return self(0b11111) }
    static var All:     LogLevel { return self(0b11111111) }
}
func == (lhs: LogLevel, rhs: LogLevel) -> Bool { return lhs.value == rhs.value }



// what's a better way than poluting the global scope?
var __logLevel: LogLevel?
var __logAsync: Bool?


// Use those class properties insted of `#define LOG_LEVEL_DEF` and `LOG_ASYNC_ENABLED`
extension DDLog {
    class var logLevel: LogLevel {
        get {
            return __logLevel ?? LogLevel.Error
        }
        set(logLevel) {
            __logLevel = logLevel
        }
    }
    
    class var logAsync: Bool {
        get {
            return (self.logLevel != LogLevel.Error) && (__logAsync ?? true)
        }
        set(logAsync) {
            __logAsync = logAsync
        }
    }
    
    class func logError (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { log(.Error, message: message, function: function, file: file, line: line) }
    class func logWarn  (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { log(.Warn,  message: message, function: function, file: file, line: line) }
    class func logInfo  (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { log(.Info,  message: message, function: function, file: file, line: line) }
    class func logDebug (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { log(.Debug, message: message, function: function, file: file, line: line) }
    
    private class func log (
        flag: LogFlag,
        message: String,
        // No need to pass those in. the defaults will do just fine
        function: String = __FUNCTION__,
        file: String = __FILE__,
        line: Int32 = __LINE__
        )
    {
        let level:LogLevel = DDLog.logLevel
        let async:Bool = (level != LogLevel.Error) && DDLog.logAsync
        
        if flag.toRaw() & level.toRaw() != 0 {
            DDLog.log(
                async,
                message: DDLogMessage(logMsg: message,
                    level: level.toRaw(),
                    flag: flag.toRaw(),
                    context: 0,
                    file: file,
                    function: function,
                    line: line,
                    tag: nil,
                    options: 0))
        }
    }
}

// Shorthands, what you'd expect
/* //Not possible due to http://openradar.appspot.com/radar?id=5773154781757440
let logError = DDLog.logError
let logWarn  = DDLog.logWarn
let logInfo  = DDLog.logInfo
let logDebug = DDLog.logDebug
*/
func logError (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { DDLog.logError(message, function: function, file: file, line: line) }
func logWarn  (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { DDLog.logWarn(message, function: function, file: file, line: line) }
func logInfo  (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { DDLog.logInfo(message, function: function, file: file, line: line) }
func logDebug (message: String, function: String = __FUNCTION__, file: String = __FILE__, line: Int32 = __LINE__) { DDLog.logDebug(message, function: function, file: file, line: line) }

swift gistfile1.swift

gistfile1.swift
import Foundation


//
//  Box.swift
//  swiftz_core
//
//  Created by Andrew Cobb on 6/9/14.
//  Copyright (c) 2014 Maxwell Swadling. All rights reserved.
//
// https://github.com/maxpow4h/swiftz/blob/master/swiftz_core/swiftz_core/Box.swift

// An immutable box, necessary for recursive datatypes (such as List) to avoid compiler crashes
public final class Box<T> {
    private let _value : () -> T

    public init(_ value : T) {
        self._value = { value }
    }

    public var value: T {
        return _value()
    }

    public func map<U>(f: T -> U) -> Box<U> {
        return Box<U>(f(value)) // TODO: file rdar, type inf fails without <U>
    }
}

enum Term {
    case TmTrue
    case TmFalse
    case TmIf(Box<Term>, Box<Term>, Box<Term>)
    case TmZero
    case TmSucc(Box<Term>)
    case TmPred(Box<Term>)
    case TmIsZero(Box<Term>)

    // We use Rob Rix’s Destructurable idea to be able to pattern match with boxed recursive enums.
    // See the destructure() method below — converting this to an extension seems a good idea.
    // https://github.com/robrix/Hammer.swift/blob/master/Hammer/Destructurable.swift
    enum DestructuredTerm {
        case TmTrue
        case TmFalse
        case TmIf(Term, Term, Term)
        case TmZero
        case TmSucc(Term)
        case TmPred(Term)
        case TmIsZero(Term)
    }

    func isnumericval () -> Bool {
        switch (self) {
        case TmZero: return true
        case let TmSucc(t1): return t1.value.isnumericval()
        default: return false
        }
    }

    func isval () -> Bool {
        switch (self) {
        case TmTrue: return true
        case TmFalse: return true
        case let t where t.isnumericval(): return true
        default: return false
        }
    }

    func eval () -> Term {
        switch self.destructure() {
        case let .TmIf(t1, t2, t3):
            return TmIf(Box(t1.eval()), Box(t2), Box(t3))

        case let .TmIf(.TmTrue, t2, _):
            return t2

        case let .TmIf(.TmFalse, _, t3):
            return t3

        case let .TmSucc(t1):
            return TmSucc(Box(t1.eval()))

        case let .TmPred(.TmZero):
            return TmZero

        case let .TmPred(TmSucc(nv1)) where nv1.value.isnumericval():
            return nv1.value

        case let .TmPred(t1):
            return TmPred(Box(t1.eval()))

        case let .TmIsZero(TmZero):
            return TmTrue

        case let .TmIsZero(TmSucc(nv1)) where nv1.value.isnumericval():
            return TmFalse

        case let .TmIsZero(t1):
            return TmIsZero(Box(t1.eval()))

        default:
            fatalError("End of the line")
        }
    }

    func destructure () -> DestructuredTerm {
        switch self {
        case TmTrue: return .TmTrue
        case TmFalse: return .TmFalse
        case TmZero: return .TmZero
        case let TmSucc(t1): return .TmSucc(t1.value)
        case let TmPred(t1): return .TmPred(t1.value)
        case let TmIsZero(t1): return .TmIsZero(t1.value)
        case let TmIf(t1, t2, t3): return .TmIf(t1.value, t2.value, t3.value)
        }
    }
}
/* Not needed anymore! :D
func ==(lhs: Term, rhs: Term) -> Bool {
    switch (lhs, rhs) {
    case (.TmTrue, .TmTrue): return true
    case (.TmFalse, .TmFalse): return true
    case (.TmZero, .TmZero): return true

    case let (.TmSucc(l), .TmSucc(r)): return l.value == r.value
    case let (.TmPred(l), .TmPred(r)): return l.value == r.value
    case let (.TmIsZero(l), .TmIsZero(r)): return l.value == r.value

    case let (.TmIf(l1, l2, l3), .TmIf(r1, r2, r3)): return l1.value == r1.value && l2.value == r2.value && l3.value == r3.value

    default: return false
    }
}
*/

swift EmojiKit.swift

EmojiKit.swift
class EmojiKitClass {
    
    enum Smilyes: String {
        
        case SmilingFaceWithOpenMouthAndSmilingEyes = "\u{1F604}"
        case SmilingFaceWithSmilingEyes = "\u{1F60A}"
        case SmilingFaceWithOpenMouths = "\u{1F603}"
        case GrinningFace = "\u{1F600}"
        case FullMoonWithFace = "\u{1F31D}"
        case JapanesePostOffice = "\u{1F3E3}"
        case Lock = "\u{1F512}"
        case Hospital = "\u{1F3E5}"
        case Paperclip = "\u{1F4CE}"
        case HeavyBlackHeart = "\u{2764}"
        case StraightRuler = "\u{1F4CF}"
        case BarChart = "\u{1F4CA}"
        case Bank = "\u{1F3E6}"
        case Pushpin = "\u{1F4CC}"
        case Clipboard = "\u{1F4CB}"
        case BlackSunWithRays = "\u{2600}"
        case Cloud = "\u{2601}"
        case MouseFace = "\u{1F42D}"
        case RadioButton = "\u{1F518}"
        case BlackRightwardsArrow = "\u{27A1}"
        case DigitTwo+CombiningEnclosingKeycap = "\u{0032 U+20E3}"
        case OncomingPoliceCar = "\u{1F694}"
        case Bathtub = "\u{1F6C1}"
        case Monorail = "\u{1F69D}"
        case TiredFace = "\u{1F62B}"
        case OncomingTaxi = "\u{1F696}"
        case LoudlyCryingFace = "\u{1F62D}"
        case Minibus = "\u{1F690}"
        case Calendar = "\u{1F4C5}"
        case PageFacingUp = "\u{1F4C4}"
        case CardIndex = "\u{1F4C7}"
        case Tear-OffCalendar = "\u{1F4C6}"
        case FileFolder = "\u{1F4C1}"
        case Dvd = "\u{1F4C0}"
        case PageWithCurl = "\u{1F4C3}"
        case OpenFileFolder = "\u{1F4C2}"
        case ChartWithDownwardsTrend = "\u{1F4C9}"
        case ChartWithUpwardsTrend = "\u{1F4C8}"
        case BlackTelephone = "\u{260E}"
        case Battery = "\u{1F50B}"
        case Right-PointingMagnifyingGlass = "\u{1F50E}"
        case Leopard = "\u{1F406}"
        case Left-PointingMagnifyingGlass = "\u{1F50D}"
        case SquaredCjkUnifiedIdeograph-55B6 = "\u{1F23A}"
        case Herb = "\u{1F33F}"
        case EarOfMaize = "\u{1F33D}"
        case EarOfRice = "\u{1F33E}"
        case Sunflower = "\u{1F33B}"
        case Blossom = "\u{1F33C}"
        case Hibiscus = "\u{1F33A}"
        case ThumbsUpSign = "\u{1F44D}"
        case AlarmClock = "\u{23F0}"
        case HourglassWithFlowingSand = "\u{23F3}"
        case WhiteMediumSmallSquare = "\u{25FD}"
        case BlackMediumSquare = "\u{25FC}"
        case WhiteMediumSquare = "\u{25FB}"
        case WavingHandSign = "\u{1F44B}"
        case OkHandSign = "\u{1F44C}"
        case CircledIdeographCongratulation = "\u{3297}"
        case Tractor = "\u{1F69C}"
        case JapaneseGoblin = "\u{1F47A}"
        case ElectricPlug = "\u{1F50C}"
        case RoundPushpin = "\u{1F4CD}"
        case HushedFace = "\u{1F62F}"
        case TwoMenHoldingHands = "\u{1F46C}"
        case Mouth = "\u{1F444}"
        case Tongue = "\u{1F445}"
        case WhiteUpPointingBackhandIndex = "\u{1F446}"
        case WhiteDownPointingBackhandIndex = "\u{1F447}"
        case Eyes = "\u{1F440}"
        case ChartWithUpwardsTrendAndYenSign = "\u{1F4B9}"
        case Ear = "\u{1F442}"
        case Nose = "\u{1F443}"
        case RegionalIndicatorSymbolLetterK+RegionalIndicatorSymbolLetterR = "\u{1F1F0 U+1F1F7}"
        case ClockFaceSeven-Thirty = "\u{1F562}"
        case ClockFaceSix-Thirty = "\u{1F561}"
        case ClockFaceFive-Thirty = "\u{1F560}"
        case WhiteLeftPointingBackhandIndex = "\u{1F448}"
        case WhiteRightPointingBackhandIndex = "\u{1F449}"
        case ClockFaceTen-Thirty = "\u{1F565}"
        case PlayingCardBlackJoker = "\u{1F0CF}"
        case SquaredCjkUnifiedIdeograph-6708 = "\u{1F237}"
        case SquaredCjkUnifiedIdeograph-6709 = "\u{1F236}"
        case SquaredCjkUnifiedIdeograph-6E80 = "\u{1F235}"
        case SquaredCjkUnifiedIdeograph-5408 = "\u{1F234}"
        case SquaredCjkUnifiedIdeograph-7A7A = "\u{1F233}"
        case SquaredCjkUnifiedIdeograph-7981 = "\u{1F232}"
        case CherryBlossom = "\u{1F338}"
        case Rose = "\u{1F339}"
        case Tulip = "\u{1F337}"
        case PalmTree = "\u{1F334}"
        case Cactus = "\u{1F335}"
        case EvergreenTree = "\u{1F332}"
        case DeciduousTree = "\u{1F333}"
        case Chestnut = "\u{1F330}"
        case SquaredCjkUnifiedIdeograph-7533 = "\u{1F238}"
        case ChristmasTree = "\u{1F384}"
        case WomansClothes = "\u{1F45A}"
        case Wedding = "\u{1F492}"
        case CoupleWithHeart = "\u{1F491}"
        case BirthdayCake = "\u{1F382}"
        case AngryFace = "\u{1F620}"
        case Sparkles = "\u{2728}"
        case CryingFace = "\u{1F622}"
        case PerseveringFace = "\u{1F623}"
        case DeliveryTruck = "\u{1F69A}"
        case DisappointedButRelievedFace = "\u{1F625}"
        case FrowningFaceWithOpenMouth = "\u{1F626}"
        case AnguishedFace = "\u{1F627}"
        case FearfulFace = "\u{1F628}"
        case WearyFace = "\u{1F629}"
        case TopWithUpwardsArrowAbove = "\u{1F51D}"
        case ClosedLockWithKey = "\u{1F510}"
        case NoOneUnderEighteenSymbol = "\u{1F51E}"
        case SquaredVs = "\u{1F19A}"
        case Key = "\u{1F511}"
        case SquaredSos = "\u{1F198}"
        case SquaredUpWithExclamationMark = "\u{1F199}"
        case Capricorn = "\u{2651}"
        case Sagittarius = "\u{2650}"
        case Pisces = "\u{2653}"
        case Aquarius = "\u{2652}"
        case SquaredCool = "\u{1F192}"
        case SquaredFree = "\u{1F193}"
        case SquaredCl = "\u{1F191}"
        case SquaredNg = "\u{1F196}"
        case SquaredOk = "\u{1F197}"
        case SquaredId = "\u{1F194}"
        case SquaredNew = "\u{1F195}"
        case Taxi = "\u{1F695}"
        case SleepyFace = "\u{1F62A}"
        case Automobile = "\u{1F697}"
        case GrimacingFace = "\u{1F62C}"
        case Ambulance = "\u{1F691}"
        case FaceWithOpenMouth = "\u{1F62E}"
        case PoliceCar = "\u{1F693}"
        case FireEngine = "\u{1F692}"
        case RecreationalVehicle = "\u{1F699}"
        case OncomingAutomobile = "\u{1F698}"
        case BeatingHeart = "\u{1F493}"
        case NegativeSquaredLatinCapitalLetterO = "\u{1F17E}"
        case NegativeSquaredLatinCapitalLetterP = "\u{1F17F}"
        case Bouquet = "\u{1F490}"
        case GrowingHeart = "\u{1F497}"
        case SparklingHeart = "\u{1F496}"
        case TwoHearts = "\u{1F495}"
        case BrokenHeart = "\u{1F494}"
        case BlueHeart = "\u{1F499}"
        case HeartWithArrow = "\u{1F498}"
        case ClinkingBeerMugs = "\u{1F37B}"
        case BabyBottle = "\u{1F37C}"
        case BeerMug = "\u{1F37A}"
        case Crocodile = "\u{1F40A}"
        case Whale = "\u{1F40B}"
        case Snail = "\u{1F40C}"
        case Snake = "\u{1F40D}"
        case Horse = "\u{1F40E}"
        case Ram = "\u{1F40F}"
        case Microphone = "\u{1F3A4}"
        case MovieCamera = "\u{1F3A5}"
        case Cinema = "\u{1F3A6}"
        case Headphone = "\u{1F3A7}"
        case CarouselHorse = "\u{1F3A0}"
        case FerrisWheel = "\u{1F3A1}"
        case RollerCoaster = "\u{1F3A2}"
        case FishingPoleAndFish = "\u{1F3A3}"
        case ArtistPalette = "\u{1F3A8}"
        case TopHat = "\u{1F3A9}"
        case FaceWithoutMouth = "\u{1F636}"
        case VideoCamera = "\u{1F4F9}"
        case AntennaWithBars = "\u{1F4F6}"
        case CheeringMegaphone = "\u{1F4E3}"
        case MobilePhoneOff = "\u{1F4F4}"
        case NoMobilePhones = "\u{1F4F5}"
        case MobilePhoneWithRightwardsArrowAtLeft = "\u{1F4F2}"
        case VibrationMode = "\u{1F4F3}"
        case Newspaper = "\u{1F4F0}"
        case MobilePhone = "\u{1F4F1}"
        case FaxMachine = "\u{1F4E0}"
        case Radio = "\u{1F4FB}"
        case Videocassette = "\u{1F4FC}"
        case Television = "\u{1F4FA}"
        case PerformingArts = "\u{1F3AD}"
        case VideoGame = "\u{1F3AE}"
        case DirectHit = "\u{1F3AF}"
        case CircusTent = "\u{1F3AA}"
        case Ticket = "\u{1F3AB}"
        case ClapperBoard = "\u{1F3AC}"
        case RunningShirtWithSash = "\u{1F3BD}"
        case RegionalIndicatorSymbolLetterG+RegionalIndicatorSymbolLetterB = "\u{1F1EC U+1F1E7}"
        case PotOfFood = "\u{1F372}"
        case Cooking = "\u{1F373}"
        case Shortcake = "\u{1F370}"
        case BentoBox = "\u{1F371}"
        case SakeBottleAndCup = "\u{1F376}"
        case WineGlass = "\u{1F377}"
        case ForkAndKnife = "\u{1F374}"
        case TeacupWithoutHandle = "\u{1F375}"
        case Rat = "\u{1F400}"
        case Mouse = "\u{1F401}"
        case CocktailGlass = "\u{1F378}"
        case TropicalDrink = "\u{1F379}"
        case Cow = "\u{1F404}"
        case BlackRight-PointingTriangle = "\u{25B6}"
        case RegionalIndicatorSymbolLetterU+RegionalIndicatorSymbolLetterS = "\u{1F1FA U+1F1F8}"
        case Rabbit = "\u{1F407}"
        case PurpleHeart = "\u{1F49C}"
        case DigitSeven+CombiningEnclosingKeycap = "\u{0037 U+20E3}"
        case GreenHeart = "\u{1F49A}"
        case NegativeSquaredLatinCapitalLetterA = "\u{1F170}"
        case NegativeSquaredLatinCapitalLetterB = "\u{1F171}"
        case RevolvingHearts = "\u{1F49E}"
        case HeartWithRibbon = "\u{1F49D}"
        case Telescope = "\u{1F52D}"
        case NoEntry = "\u{26D4}"
        case TwistedRightwardsArrows = "\u{1F500}"
        case CopyrightSign = "\u{00A9}"
        case LargeRedCircle = "\u{1F534}"
        case LargeBlueCircle = "\u{1F535}"
        case LargeOrangeDiamond = "\u{1F536}"
        case LargeBlueDiamond = "\u{1F537}"
        case JapaneseSymbolForBeginner = "\u{1F530}"
        case TridentEmblem = "\u{1F531}"
        case BlackSquareButton = "\u{1F532}"
        case WhiteSquareButton = "\u{1F533}"
        case SmallOrangeDiamond = "\u{1F538}"
        case WhiteUpPointingIndex = "\u{261D}"
        case SunsetOverBuildings = "\u{1F307}"
        case CityscapeAtDusk = "\u{1F306}"
        case Sunrise = "\u{1F305}"
        case SunriseOverMountains = "\u{1F304}"
        case NightWithStars = "\u{1F303}"
        case ClosedUmbrella = "\u{1F302}"
        case SunBehindCloud = "\u{26C5}"
        case SnowmanWithoutSnow = "\u{26C4}"
        case BridgeAtNight = "\u{1F309}"
        case Rainbow = "\u{1F308}"
        case EarthGlobeAsia-Australia = "\u{1F30F}"
        case EarthGlobeAmericas = "\u{1F30E}"
        case EarthGlobeEurope-Africa = "\u{1F30D}"
        case MilkyWay = "\u{1F30C}"
        case Volcano = "\u{1F30B}"
        case WaterWave = "\u{1F30A}"
        case SouthWestArrow = "\u{2199}"
        case NorthWestArrow = "\u{2196}"
        case NorthEastArrow = "\u{2197}"
        case LeftRightArrow = "\u{2194}"
        case UpDownArrow = "\u{2195}"
        case RegionalIndicatorSymbolLetterE+RegionalIndicatorSymbolLetterS = "\u{1F1EA U+1F1F8}"
        case Down-PointingSmallRedTriangle = "\u{1F53D}"
        case BlackQuestionMarkOrnament = "\u{2753}"
        case WhiteQuestionMarkOrnament = "\u{2754}"
        case WhiteExclamationMarkOrnament = "\u{2755}"
        case Down-PointingRedTriangle = "\u{1F53B}"
        case HeavyExclamationMarkSymbol = "\u{2757}"
        case BallotBoxWithCheck = "\u{2611}"
        case LowBrightnessSymbol = "\u{1F505}"
        case HotBeverage = "\u{2615}"
        case UmbrellaWithRainDrops = "\u{2614}"
        case SpeakerWithCancellationStroke = "\u{1F507}"
        case HighBrightnessSymbol = "\u{1F506}"
        case RegisteredSign = "\u{00AE}"
        case Customs = "\u{1F6C3}"
        case PassportControl = "\u{1F6C2}"
        case Postbox = "\u{1F4EE}"
        case Bath = "\u{1F6C0}"
        case OpenMailboxWithRaisedFlag = "\u{1F4EC}"
        case ClosedMailboxWithRaisedFlag = "\u{1F4EB}"
        case ClosedMailboxWithLoweredFlag = "\u{1F4EA}"
        case BaggageClaim = "\u{1F6C4}"
        case Package = "\u{1F4E6}"
        case Hotel = "\u{1F3E8}"
        case LoveHotel = "\u{1F3E9}"
        case DigitSix+CombiningEnclosingKeycap = "\u{0036 U+20E3}"
        case CurrencyExchange = "\u{1F4B1}"
        case BanknoteWithEuroSign = "\u{1F4B6}"
        case BanknoteWithPoundSign = "\u{1F4B7}"
        case BanknoteWithYenSign = "\u{1F4B4}"
        case BanknoteWithDollarSign = "\u{1F4B5}"
        case MahjongTileRedDragon = "\u{1F004}"
        case HouseWithGarden = "\u{1F3E1}"
        case OfficeBuilding = "\u{1F3E2}"
        case DigitOne+CombiningEnclosingKeycap = "\u{0031 U+20E3}"
        case EuropeanPostOffice = "\u{1F3E4}"
        case BlackLeft-PointingDoubleTriangle = "\u{23EA}"
        case BlackUp-PointingDoubleTriangle = "\u{23EB}"
        case BlackDown-PointingDoubleTriangle = "\u{23EC}"
        case PersonalComputer = "\u{1F4BB}"
        case Briefcase = "\u{1F4BC}"
        case Seat = "\u{1F4BA}"
        case OpticalDisc = "\u{1F4BF}"
        case BlackRight-PointingDoubleTriangle = "\u{23E9}"
        case Minidisc = "\u{1F4BD}"
        case FloppyDisk = "\u{1F4BE}"
        case ConvenienceStore = "\u{1F3EA}"
        case School = "\u{1F3EB}"
        case DepartmentStore = "\u{1F3EC}"
        case Factory = "\u{1F3ED}"
        case IzakayaLantern = "\u{1F3EE}"
        case JapaneseCastle = "\u{1F3EF}"
        case E-MailSymbol = "\u{1F4E7}"
        case JapaneseOgre = "\u{1F479}"
        case InboxTray = "\u{1F4E5}"
        case OutboxTray = "\u{1F4E4}"
        case DigitZero+CombiningEnclosingKeycap = "\u{0030 U+20E3}"
        case PublicAddressLoudspeaker = "\u{1F4E2}"
        case SatelliteAntenna = "\u{1F4E1}"
        case Princess = "\u{1F478}"
        case EnvelopeWithDownwardsArrowAbove = "\u{1F4E9}"
        case IncomingEnvelope = "\u{1F4E8}"
        case WavyDash = "\u{3030}"
        case PersonWithBlondHair = "\u{1F471}"
        case BrideWithVeil = "\u{1F470}"
        case ManWithTurban = "\u{1F473}"
        case ManWithGuaPiMao = "\u{1F472}"
        case OlderWoman = "\u{1F475}"
        case OlderMan = "\u{1F474}"
        case ConstructionWorker = "\u{1F477}"
        case Baby = "\u{1F476}"
        case DisappointedFace = "\u{1F61E}"
        case FaceWithStuck-OutTongueAndTightly-ClosedEyes = "\u{1F61D}"
        case WorriedFace = "\u{1F61F}"
        case KissingFaceWithClosedEyes = "\u{1F61A}"
        case FaceWithStuck-OutTongueAndWinkingEye = "\u{1F61C}"
        case FaceWithStuck-OutTongue = "\u{1F61B}"
        case Watermelon = "\u{1F349}"
        case Melon = "\u{1F348}"
        case LeafFlutteringInWind = "\u{1F343}"
        case FallenLeaf = "\u{1F342}"
        case MapleLeaf = "\u{1F341}"
        case FourLeafClover = "\u{1F340}"
        case Grapes = "\u{1F347}"
        case Aubergine = "\u{1F346}"
        case Tomato = "\u{1F345}"
        case Mushroom = "\u{1F344}"
        case HeavyCheckMark = "\u{2714}"
        case Cat = "\u{1F408}"
        case HeavyMultiplicationX = "\u{2716}"
        case BlackNib = "\u{2712}"
        case Dragon = "\u{1F409}"
        case Banana = "\u{1F34C}"
        case Lemon = "\u{1F34B}"
        case Tangerine = "\u{1F34A}"
        case GreenApple = "\u{1F34F}"
        case RedApple = "\u{1F34E}"
        case Pineapple = "\u{1F34D}"
        case WhiteSmallSquare = "\u{25AB}"
        case BabyAngel = "\u{1F47C}"
        case BlackSmallSquare = "\u{25AA}"
        case AlienMonster = "\u{1F47E}"
        case FaceThrowingAKiss = "\u{1F618}"
        case Imp = "\u{1F47F}"
        case ConfusedFace = "\u{1F615}"
        case PensiveFace = "\u{1F614}"
        case KissingFace = "\u{1F617}"
        case ConfoundedFace = "\u{1F616}"
        case ExpressionlessFace = "\u{1F611}"
        case NeutralFace = "\u{1F610}"
        case FaceWithColdSweat = "\u{1F613}"
        case UnamusedFace = "\u{1F612}"
        case ThumbsDownSign = "\u{1F44E}"
        case BlackMediumSmallSquare = "\u{25FE}"
        case PartAlternationMark = "\u{303D}"
        case DoubleExclamationMark = "\u{203C}"
        case CircledIdeographSecret = "\u{3299}"
        case RelievedFace = "\u{1F60C}"
        case Ox = "\u{1F402}"
        case FistedHandSign = "\u{1F44A}"
        case WaterBuffalo = "\u{1F403}"
        case SpeechBalloon = "\u{1F4AC}"
        case DizzySymbol = "\u{1F4AB}"
        case FlexedBiceps = "\u{1F4AA}"
        case SquaredCjkUnifiedIdeograph-6307 = "\u{1F22F}"
        case WhiteFlower = "\u{1F4AE}"
        case Tiger = "\u{1F405}"
        case BlackSpadeSuit = "\u{2660}"
        case MusicalScore = "\u{1F3BC}"
        case BlackClubSuit = "\u{2663}"
        case TennisRacquetAndBall = "\u{1F3BE}"
        case BlackHeartSuit = "\u{2665}"
        case BlackDiamondSuit = "\u{2666}"
        case SkiAndSkiBoot = "\u{1F3BF}"
        case HotSprings = "\u{2668}"
        case SteamLocomotive = "\u{1F682}"
        case RailwayCar = "\u{1F683}"
        case Rocket = "\u{1F680}"
        case Helicopter = "\u{1F681}"
        case Train = "\u{1F686}"
        case Metro = "\u{1F687}"
        case High-SpeedTrain = "\u{1F684}"
        case High-SpeedTrainWithBulletNose = "\u{1F685}"
        case LightRail = "\u{1F688}"
        case Station = "\u{1F689}"
        case LockWithInkPen = "\u{1F50F}"
        case Pill = "\u{1F48A}"
        case KissMark = "\u{1F48B}"
        case LoveLetter = "\u{1F48C}"
        case Ring = "\u{1F48D}"
        case RegionalIndicatorSymbolLetterC+RegionalIndicatorSymbolLetterN = "\u{1F1E8 U+1F1F3}"
        case Kiss = "\u{1F48F}"
        case Pencil = "\u{270F}"
        case Skull = "\u{1F480}"
        case InformationDeskPerson = "\u{1F481}"
        case Guardsman = "\u{1F482}"
        case Dancer = "\u{1F483}"
        case Lipstick = "\u{1F484}"
        case NailPolish = "\u{1F485}"
        case FaceMassage = "\u{1F486}"
        case Haircut = "\u{1F487}"
        case BarberPole = "\u{1F488}"
        case Syringe = "\u{1F489}"
        case Moyai = "\u{1F5FF}"
        case SilhouetteOfJapan = "\u{1F5FE}"
        case StatueOfLiberty = "\u{1F5FD}"
        case Bus = "\u{1F68C}"
        case Tram = "\u{1F68A}"
        case BusStop = "\u{1F68F}"
        case OncomingBus = "\u{1F68D}"
        case Trolleybus = "\u{1F68E}"
        case ClappingHandsSign = "\u{1F44F}"
        case Billiards = "\u{1F3B1}"
        case SlotMachine = "\u{1F3B0}"
        case Bowling = "\u{1F3B3}"
        case GameDie = "\u{1F3B2}"
        case MusicalNote = "\u{1F3B5}"
        case FlowerPlayingCards = "\u{1F3B4}"
        case Saxophone = "\u{1F3B7}"
        case MultipleMusicalNotes = "\u{1F3B6}"
        case MusicalKeyboard = "\u{1F3B9}"
        case Guitar = "\u{1F3B8}"
        case PileOfPoo = "\u{1F4A9}"
        case Ghost = "\u{1F47B}"
        case Bomb = "\u{1F4A3}"
        case AngerSymbol = "\u{1F4A2}"
        case ElectricLightBulb = "\u{1F4A1}"
        case DiamondShapeWithADotInside = "\u{1F4A0}"
        case Droplet = "\u{1F4A7}"
        case SplashingSweatSymbol = "\u{1F4A6}"
        case CollisionSymbol = "\u{1F4A5}"
        case ExtraterrestrialAlien = "\u{1F47D}"
        case ClockFaceFourOclock = "\u{1F553}"
        case SunWithFace = "\u{1F31E}"
        case GlowingStar = "\u{1F31F}"
        case NewMoonWithFace = "\u{1F31A}"
        case FirstQuarterMoonWithFace = "\u{1F31B}"
        case LastQuarterMoonWithFace = "\u{1F31C}"
        case MonkeyFace = "\u{1F435}"
        case HorseFace = "\u{1F434}"
        case PigFace = "\u{1F437}"
        case DogFace = "\u{1F436}"
        case CatFace = "\u{1F431}"
        case RabbitFace = "\u{1F430}"
        case SpoutingWhale = "\u{1F433}"
        case DragonFace = "\u{1F432}"
        case HamsterFace = "\u{1F439}"
        case FrogFace = "\u{1F438}"
        case ClockFaceOneOclock = "\u{1F550}"
        case PartyPopper = "\u{1F389}"
        case Balloon = "\u{1F388}"
        case UpwardsBlackArrow = "\u{2B06}"
        case DownwardsBlackArrow = "\u{2B07}"
        case FatherChristmas = "\u{1F385}"
        case LeftwardsBlackArrow = "\u{2B05}"
        case Jack-O-Lantern = "\u{1F383}"
        case Anchor = "\u{2693}"
        case WrappedPresent = "\u{1F381}"
        case Ribbon = "\u{1F380}"
        case Church = "\u{26EA}"
        case CircledLatinCapitalLetterM = "\u{24C2}"
        case Camera = "\u{1F4F7}"
        case ExclamationQuestionMark = "\u{2049}"
        case YellowHeart = "\u{1F49B}"
        case TokyoTower = "\u{1F5FC}"
        case CarpStreamer = "\u{1F38F}"
        case JapaneseDolls = "\u{1F38E}"
        case PineDecoration = "\u{1F38D}"
        case CrossedFlags = "\u{1F38C}"
        case TanabataTree = "\u{1F38B}"
        case ConfettiBall = "\u{1F38A}"
        case PawPrints = "\u{1F43E}"
        case PigNose = "\u{1F43D}"
        case ClockwiseDownwardsAndUpwardsOpenCircleArrows = "\u{1F503}"
        case ClockwiseRightwardsAndLeftwardsOpenCircleArrowsWithCircledOneOverlay = "\u{1F502}"
        case WolfFace = "\u{1F43A}"
        case AnticlockwiseDownwardsAndUpwardsOpenCircleArrows = "\u{1F504}"
        case PandaFace = "\u{1F43C}"
        case BearFace = "\u{1F43B}"
        case SpeakerWithOneSoundWave = "\u{1F509}"
        case WaxingGibbousMoonSymbol = "\u{1F314}"
        case FullMoonSymbol = "\u{1F315}"
        case WaningGibbousMoonSymbol = "\u{1F316}"
        case LastQuarterMoonSymbol = "\u{1F317}"
        case GlobeWithMeridians = "\u{1F310}"
        case NewMoonSymbol = "\u{1F311}"
        case WaxingCrescentMoonSymbol = "\u{1F312}"
        case FirstQuarterMoonSymbol = "\u{1F313}"
        case ClockFaceEightOclock = "\u{1F557}"
        case WaningCrescentMoonSymbol = "\u{1F318}"
        case CrescentMoon = "\u{1F319}"
        case RegionalIndicatorSymbolLetterF+RegionalIndicatorSymbolLetterR = "\u{1F1EB U+1F1F7}"
        case FaceWithOkGesture = "\u{1F646}"
        case PersonBowingDeeply = "\u{1F647}"
        case FaceWithNoGoodGesture = "\u{1F645}"
        case WearyCatFace = "\u{1F640}"
        case Sparkle = "\u{2747}"
        case Snowflake = "\u{2744}"
        case See-No-EvilMonkey = "\u{1F648}"
        case Hear-No-EvilMonkey = "\u{1F649}"
        case WomensSymbol = "\u{1F6BA}"
        case Restroom = "\u{1F6BB}"
        case BabySymbol = "\u{1F6BC}"
        case Toilet = "\u{1F6BD}"
        case WaterCloset = "\u{1F6BE}"
        case Shower = "\u{1F6BF}"
        case RightwardsArrowWithHook = "\u{21AA}"
        case KissingFaceWithSmilingEyes = "\u{1F619}"
        case PotableWaterSymbol = "\u{1F6B0}"
        case Non-PotableWaterSymbol = "\u{1F6B1}"
        case Bicycle = "\u{1F6B2}"
        case NoBicycles = "\u{1F6B3}"
        case Bicyclist = "\u{1F6B4}"
        case MountainBicyclist = "\u{1F6B5}"
        case Pedestrian = "\u{1F6B6}"
        case NoPedestrians = "\u{1F6B7}"
        case ChildrenCrossing = "\u{1F6B8}"
        case MensSymbol = "\u{1F6B9}"
        case HeartDecoration = "\u{1F49F}"
        case LeftwardsArrowWithHook = "\u{21A9}"
        case EuropeanCastle = "\u{1F3F0}"
        case InformationSource = "\u{2139}"
        case WomansHat = "\u{1F452}"
        case PersonWithFoldedHands = "\u{1F64F}"
        case PersonFrowning = "\u{1F64D}"
        case PersonWithPoutingFace = "\u{1F64E}"
        case HappyPersonRaisingOneHand = "\u{1F64B}"
        case PersonRaisingBothHandsInCelebration = "\u{1F64C}"
        case Speak-No-EvilMonkey = "\u{1F64A}"
        case NegativeSquaredCrossMark = "\u{274E}"
        case RugbyFootball = "\u{1F3C9}"
        case CrossMark = "\u{274C}"
        case SquaredCjkUnifiedIdeograph-7121 = "\u{1F21A}"
        case CookedRice = "\u{1F35A}"
        case CurryAndRice = "\u{1F35B}"
        case SteamingBowl = "\u{1F35C}"
        case Spaghetti = "\u{1F35D}"
        case Bread = "\u{1F35E}"
        case FrenchFries = "\u{1F35F}"
        case SmallBlueDiamond = "\u{1F539}"
        case WomanWithBunnyEars = "\u{1F46F}"
        case TwoWomenHoldingHands = "\u{1F46D}"
        case PoliceOfficer = "\u{1F46E}"
        case ManAndWomanHoldingHands = "\u{1F46B}"
        case AutomatedTellerMachine = "\u{1F3E7}"
        case Family = "\u{1F46A}"
        case NotebookWithDecorativeCover = "\u{1F4D4}"
        case ClosedBook = "\u{1F4D5}"
        case OpenBook = "\u{1F4D6}"
        case GreenBook = "\u{1F4D7}"
        case TriangularRuler = "\u{1F4D0}"
        case BookmarkTabs = "\u{1F4D1}"
        case Ledger = "\u{1F4D2}"
        case Notebook = "\u{1F4D3}"
        case MediumWhiteCircle = "\u{26AA}"
        case MediumBlackCircle = "\u{26AB}"
        case BlueBook = "\u{1F4D8}"
        case OrangeBook = "\u{1F4D9}"
        case Memo = "\u{1F4DD}"
        case TelephoneReceiver = "\u{1F4DE}"
        case Pager = "\u{1F4DF}"
        case Foggy = "\u{1F301}"
        case NameBadge = "\u{1F4DB}"
        case Scroll = "\u{1F4DC}"
        case HighVoltageSign = "\u{26A1}"
        case WarningSign = "\u{26A0}"
        case Cyclone = "\u{1F300}"
        case HundredPointsSymbol = "\u{1F4AF}"
        case NumberSign+CombiningEnclosingKeycap = "\u{0023 U+20E3}"
        case ThoughtBalloon = "\u{1F4AD}"
        case Trumpet = "\u{1F3BA}"
        case Man = "\u{1F468}"
        case Woman = "\u{1F469}"
        case Boy = "\u{1F466}"
        case Girl = "\u{1F467}"
        case BustInSilhouette = "\u{1F464}"
        case BustsInSilhouette = "\u{1F465}"
        case WomansBoots = "\u{1F462}"
        case Footprints = "\u{1F463}"
        case High-HeeledShoe = "\u{1F460}"
        case WomansSandal = "\u{1F461}"
        case RiceCracker = "\u{1F358}"
        case RiceBall = "\u{1F359}"
        case Violin = "\u{1F3BB}"
        case Pear = "\u{1F350}"
        case Peach = "\u{1F351}"
        case Cherries = "\u{1F352}"
        case Strawberry = "\u{1F353}"
        case Hamburger = "\u{1F354}"
        case SliceOfPizza = "\u{1F355}"
        case MeatOnBone = "\u{1F356}"
        case PoultryLeg = "\u{1F357}"
        case BlackScissors = "\u{2702}"
        case ClockFaceFiveOclock = "\u{1F554}"
        case WhiteHeavyCheckMark = "\u{2705}"
        case CurlyLoop = "\u{27B0}"
        case Envelope = "\u{2709}"
        case Airplane = "\u{2708}"
        case ClockFaceEleven-Thirty = "\u{1F566}"
        case SmilingFaceWithHorns = "\u{1F608}"
        case WinkingFace = "\u{1F609}"
        case RegionalIndicatorSymbolLetterD+RegionalIndicatorSymbolLetterE = "\u{1F1E9 U+1F1EA}"
        case FaceWithTearsOfJoy = "\u{1F602}"
        case SmilingFaceWithOpenMouth = "\u{1F603}"
        case GrinningFace = "\u{1F600}"
        case GrinningFaceWithSmilingEyes = "\u{1F601}"
        case SmilingFaceWithOpenMouthAndTightly-ClosedEyes = "\u{1F606}"
        case SmilingFaceWithHalo = "\u{1F607}"
        case SmilingFaceWithOpenMouthAndSmilingEyes = "\u{1F604}"
        case SmilingFaceWithOpenMouthAndColdSweat = "\u{1F605}"
        case RegionalIndicatorSymbolLetterI+RegionalIndicatorSymbolLetterT = "\u{1F1EE U+1F1F9}"
        case ClockFaceTenOclock = "\u{1F559}"
        case Ophiuchus = "\u{26CE}"
        case WheelchairSymbol = "\u{267F}"
        case BlackUniversalRecyclingSymbol = "\u{267B}"
        case HeavyPlusSign = "\u{2795}"
        case HeavyMinusSign = "\u{2796}"
        case HeavyDivisionSign = "\u{2797}"
        case DigitEight+CombiningEnclosingKeycap = "\u{0038 U+20E3}"
        case ClockFaceSevenOclock = "\u{1F556}"
        case SouthEastArrow = "\u{2198}"
        case Octopus = "\u{1F419}"
        case Elephant = "\u{1F418}"
        case MansShoe = "\u{1F45E}"
        case Microscope = "\u{1F52C}"
        case FaceSavouringDeliciousFood = "\u{1F60B}"
        case Watch = "\u{231A}"
        case Hourglass = "\u{231B}"
        case SmilingFaceWithSmilingEyes = "\u{1F60A}"
        case SmirkingFace = "\u{1F60F}"
        case SmilingFaceWithHeart-ShapedEyes = "\u{1F60D}"
        case SmilingFaceWithSunglasses = "\u{1F60E}"
        case VictoryHand = "\u{270C}"
        case RaisedHand = "\u{270B}"
        case RaisedFist = "\u{270A}"
        case SquaredCjkUnifiedIdeograph-5272 = "\u{1F239}"
        case Pouch = "\u{1F45D}"
        case ClockFaceTwo-Thirty = "\u{1F55D}"
        case Seedling = "\u{1F331}"
        case ClockFaceEight-Thirty = "\u{1F563}"
        case Up-PointingRedTriangle = "\u{1F53A}"
        case Goat = "\u{1F410}"
        case BlackLeft-PointingTriangle = "\u{25C0}"
        case Up-PointingSmallRedTriangle = "\u{1F53C}"
        case Pig = "\u{1F416}"
        case DigitFour+CombiningEnclosingKeycap = "\u{0034 U+20E3}"
        case Handbag = "\u{1F45C}"
        case WhiteLargeSquare = "\u{2B1C}"
        case BlackLargeSquare = "\u{2B1B}"
        case BactrianCamel = "\u{1F42B}"
        case Dolphin = "\u{1F42C}"
        case DromedaryCamel = "\u{1F42A}"
        case TigerFace = "\u{1F42F}"
        case AmericanFootball = "\u{1F3C8}"
        case CowFace = "\u{1F42E}"
        case Trophy = "\u{1F3C6}"
        case HorseRacing = "\u{1F3C7}"
        case Surfer = "\u{1F3C4}"
        case Snowboarder = "\u{1F3C2}"
        case Runner = "\u{1F3C3}"
        case BasketballAndHoop = "\u{1F3C0}"
        case ChequeredFlag = "\u{1F3C1}"
        case GemStone = "\u{1F48E}"
        case RegionalIndicatorSymbolLetterR+RegionalIndicatorSymbolLetterU = "\u{1F1F7 U+1F1FA}"
        case BackWithLeftwardsArrowAbove = "\u{1F519}"
        case Turtle = "\u{1F422}"
        case HatchingChick = "\u{1F423}"
        case TropicalFish = "\u{1F420}"
        case Blowfish = "\u{1F421}"
        case Bird = "\u{1F426}"
        case Penguin = "\u{1F427}"
        case BabyChick = "\u{1F424}"
        case Front-FacingBabyChick = "\u{1F425}"
        case Koala = "\u{1F428}"
        case Poodle = "\u{1F429}"
        case Swimmer = "\u{1F3CA}"
        case MountainRailway = "\u{1F69E}"
        case CircledIdeographAccept = "\u{1F251}"
        case CircledIdeographAdvantage = "\u{1F250}"
        case DigitFive+CombiningEnclosingKeycap = "\u{0035 U+20E3}"
        case WindChime = "\u{1F390}"
        case MoonViewingCeremony = "\u{1F391}"
        case SchoolSatchel = "\u{1F392}"
        case GraduationCap = "\u{1F393}"
        case SuspensionRailway = "\u{1F69F}"
        case ClockFaceTwelve-Thirty = "\u{1F567}"
        case FaceWithLookOfTriumph = "\u{1F624}"
        case Fountain = "\u{26F2}"
        case FlagInHole = "\u{26F3}"
        case Sailboat = "\u{26F5}"
        case ArticulatedLorry = "\u{1F69B}"
        case CatFaceWithWrySmile = "\u{1F63C}"
        case SmilingCatFaceWithHeart-ShapedEyes = "\u{1F63B}"
        case SmilingCatFaceWithOpenMouth = "\u{1F63A}"
        case Necktie = "\u{1F454}"
        case Eyeglasses = "\u{1F453}"
        case CryingCatFace = "\u{1F63F}"
        case PoutingCatFace = "\u{1F63E}"
        case KissingCatFaceWithClosedEyes = "\u{1F63D}"
        case Bookmark = "\u{1F516}"
        case LinkSymbol = "\u{1F517}"
        case Bell = "\u{1F514}"
        case BellWithCancellationStroke = "\u{1F515}"
        case AthleticShoe = "\u{1F45F}"
        case OpenLock = "\u{1F513}"
        case Bikini = "\u{1F459}"
        case Kimono = "\u{1F458}"
        case ShootingStar = "\u{1F320}"
        case WhiteSmilingFace = "\u{263A}"
        case MountFuji = "\u{1F5FB}"
        case PoutingFace = "\u{1F621}"
        case ClockFaceNine-Thirty = "\u{1F564}"
        case FlushedFace = "\u{1F633}"
        case AstonishedFace = "\u{1F632}"
        case FaceScreamingInFear = "\u{1F631}"
        case FaceWithOpenMouthAndColdSweat = "\u{1F630}"
        case FaceWithMedicalMask = "\u{1F637}"
        case Purse = "\u{1F45B}"
        case DizzyFace = "\u{1F635}"
        case SleepingFace = "\u{1F634}"
        case KeycapTen = "\u{1F51F}"
        case EightSpokedAsterisk = "\u{2733}"
        case CatFaceWithTearsOfJoy = "\u{1F639}"
        case GrinningCatFaceWithSmilingEyes = "\u{1F638}"
        case OnWithExclamationMarkWithLeftRightArrowAbove = "\u{1F51B}"
        case SoonWithRightwardsArrowAbove = "\u{1F51C}"
        case EightPointedBlackStar = "\u{2734}"
        case EndWithLeftwardsArrowAbove = "\u{1F51A}"
        case DigitThree+CombiningEnclosingKeycap = "\u{0033 U+20E3}"
        case Tent = "\u{26FA}"
        case DigitNine+CombiningEnclosingKeycap = "\u{0039 U+20E3}"
        case FuelPump = "\u{26FD}"
        case ClockwiseRightwardsAndLeftwardsOpenCircleArrows = "\u{1F501}"
        case TriangularFlagOnPost = "\u{1F6A9}"
        case PoliceCarsRevolvingLight = "\u{1F6A8}"
        case PostalHorn = "\u{1F4EF}"
        case HorizontalTrafficLight = "\u{1F6A5}"
        case Speedboat = "\u{1F6A4}"
        case ConstructionSign = "\u{1F6A7}"
        case VerticalTrafficLight = "\u{1F6A6}"
        case AerialTramway = "\u{1F6A1}"
        case MountainCableway = "\u{1F6A0}"
        case Rowboat = "\u{1F6A3}"
        case Ship = "\u{1F6A2}"
        case OpenMailboxWithLoweredFlag = "\u{1F4ED}"
        case TradeMarkSign = "\u{2122}"
        case Aries = "\u{2648}"
        case Taurus = "\u{2649}"
        case LeftLuggage = "\u{1F6C5}"
        case RegionalIndicatorSymbolLetterJ+RegionalIndicatorSymbolLetterP = "\u{1F1EF U+1F1F5}"
        case ClockFaceTwelveOclock = "\u{1F55B}"
        case ClockFaceOne-Thirty = "\u{1F55C}"
        case WhiteMediumStar = "\u{2B50}"
        case ClockFaceElevenOclock = "\u{1F55A}"
        case HeavyLargeCircle = "\u{2B55}"
        case ClockFaceFour-Thirty = "\u{1F55F}"
        case InputSymbolForNumbers = "\u{1F522}"
        case Scorpius = "\u{264F}"
        case Virgo = "\u{264D}"
        case Libra = "\u{264E}"
        case Cancer = "\u{264B}"
        case Leo = "\u{264C}"
        case Gemini = "\u{264A}"
        case NegativeSquaredAb = "\u{1F18E}"
        case ClockFaceThree-Thirty = "\u{1F55E}"
        case MoneyBag = "\u{1F4B0}"
        case PutLitterInItsPlaceSymbol = "\u{1F6AE}"
        case NoSmokingSymbol = "\u{1F6AD}"
        case DoNotLitterSymbol = "\u{1F6AF}"
        case Door = "\u{1F6AA}"
        case SmokingSymbol = "\u{1F6AC}"
        case NoEntrySign = "\u{1F6AB}"
        case SoccerBall = "\u{26BD}"
        case Baseball = "\u{26BE}"
        case ClockFaceSixOclock = "\u{1F555}"
        case ClockFaceThreeOclock = "\u{1F552}"
        case SixPointedStarWithMiddleDot = "\u{1F52F}"
        case CrystalBall = "\u{1F52E}"
        case ClockFaceTwoOclock = "\u{1F551}"
        case SpeakerWithThreeSoundWaves = "\u{1F50A}"
        case Pistol = "\u{1F52B}"
        case Hocho = "\u{1F52A}"
        case FireworkSparkler = "\u{1F387}"
        case ClockFaceNineOclock = "\u{1F558}"
        case HeavyDollarSign = "\u{1F4B2}"
        case Books = "\u{1F4DA}"
        case FishCakeWithSwirlDesign = "\u{1F365}"
        case FriedShrimp = "\u{1F364}"
        case ShavedIce = "\u{1F367}"
        case SoftIceCream = "\u{1F366}"
        case Dango = "\u{1F361}"
        case RoastedSweetPotato = "\u{1F360}"
        case Sushi = "\u{1F363}"
        case Oden = "\u{1F362}"
        case Rooster = "\u{1F413}"
        case Monkey = "\u{1F412}"
        case Sheep = "\u{1F411}"
        case Boar = "\u{1F417}"
        case Doughnut = "\u{1F369}"
        case IceCream = "\u{1F368}"
        case Dog = "\u{1F415}"
        case Chicken = "\u{1F414}"
        case DashSymbol = "\u{1F4A8}"
        case Fireworks = "\u{1F386}"
        case CreditCard = "\u{1F4B3}"
        case SquaredKatakanaSa = "\u{1F202}"
        case SquaredKatakanaKoko = "\u{1F201}"
        case Dress = "\u{1F457}"
        case Jeans = "\u{1F456}"
        case T-Shirt = "\u{1F455}"
        case Custard = "\u{1F36E}"
        case Lollipop = "\u{1F36D}"
        case HoneyPot = "\u{1F36F}"
        case Cookie = "\u{1F36A}"
        case Candy = "\u{1F36C}"
        case ChocolateBar = "\u{1F36B}"
        case Ant = "\u{1F41C}"
        case Bug = "\u{1F41B}"
        case SpiralShell = "\u{1F41A}"
        case Fish = "\u{1F41F}"
        case LadyBeetle = "\u{1F41E}"
        case Honeybee = "\u{1F41D}"
        case Wrench = "\u{1F527}"
        case ElectricTorch = "\u{1F526}"
        case Fire = "\u{1F525}"
        case InputSymbolForLatinLetters = "\u{1F524}"
        case InputSymbolForSymbols = "\u{1F523}"
        case Crown = "\u{1F451}"
        case InputSymbolForLatinSmallLetters = "\u{1F521}"
        case InputSymbolForLatinCapitalLetters = "\u{1F520}"
        case OpenHandsSign = "\u{1F450}"
        case ArrowPointingRightwardsThenCurvingUpwards = "\u{2934}"
        case ArrowPointingRightwardsThenCurvingDownwards = "\u{2935}"
        case NutAndBolt = "\u{1F529}"
        case Hammer = "\u{1F528}"
        case HouseBuilding = "\u{1F3E0}"
        case SleepingSymbol = "\u{1F4A4}"
        case MoneyWithWings = "\u{1F4B8}"
        
        
    }
    
}

swift 在swift中获取内部函数指针

在swift中获取内部函数指针

peekFunc.swift
/// See
///   https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift
///   https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c
/// to find why this works
func peekFunc<A,R>(f:A->R)->(fp:Int, ctx:Int) {
    let (hi, lo):(Int, Int) = reinterpretCast(f)
    let offset = sizeof(Int) == 8 ? 16 : 12
    let ptr  = UnsafePointer<Int>(lo+offset)
    return (ptr.memory, ptr.successor().memory)
}
@infix func === <A,R>(lhs:A->R,rhs:A->R)->Bool {
    let (tl, tr) = (peekFunc(lhs), peekFunc(rhs))
    return tl.0 == tr.0 && tl.1 == tr.1
}
// simple functions
func genericId<T>(t:T)->T { return t }
func incr(i:Int)->Int { return i + 1 }
var f:Int->Int = genericId
var g = f;      println("(f === g) == \(f === g)")
f = genericId;  println("(f === g) == \(f === g)")
f = g;          println("(f === g) == \(f === g)")
// closures
func mkcounter()->()->Int {
    var count = 0;
    return { count++ }
}
var c0 = mkcounter()
var c1 = mkcounter()
var c2 = c0
println("peekFunc(c0) == \(peekFunc(c0))")
println("peekFunc(c1) == \(peekFunc(c1))")
println("peekFunc(c2) == \(peekFunc(c2))")
println("(c0() == c1()) == \(c0() == c1())") // true : both are called once
println("(c0() == c2()) == \(c0() == c2())") // false: because c0() means c2()
println("(c0 === c1) == \(c0 === c1)")
println("(c0 === c2) == \(c0 === c2)")

swift LCS-diff.swift

LCS-diff.swift
import Swift


func LCS<T: Equatable>(a: [T], b: [T]) -> [[UInt]] {
    let rows = a.count + 1
    let cols = b.count + 1

    var matrix: [[UInt]] = Array(count: rows, repeatedValue: Array(count: cols, repeatedValue: 0))

    for i in 1..<rows {
        for j in 1..<cols {
            if a[i - 1] == b[j - 1] {
                matrix[i][j] = matrix[i - 1][j - 1] + 1
            }
            else {
                matrix[i][j] = max(matrix[i - 1][j], matrix[i][j - 1])
            }
        }
    }

    return matrix;
}

enum Change<T> : Printable, DebugPrintable {
    case Insertion(index: Int, value: @autoclosure () -> T)
    case Removal(index: Int, value: @autoclosure () -> T)

    var description: String {
        switch (self) {
        case let .Insertion(index, value): return "Insertion at \(index), string: \(value())"
        case let .Removal(index, value): return "Removal from \(index), string: \(value())"
        }
    }

    var debugDescription: String {
        return self.description
    }
}

func arrayDiffIter<T: Equatable>(LCS: [[UInt]], i: Int, j: Int, a: [T], b: [T], acc: [Change<T>]) -> [Change<T>] {
    if i > 0 && j > 0 && a[i - 1] == b[j - 1] {
        return arrayDiffIter(LCS, i - 1, j - 1, a, b, acc)
    }
    else if j > 0 && (i == 0 || LCS[i][j - 1] >= LCS[i - 1][j]) {
        let insertion = Change.Insertion(index: j - 1, value: b[j - 1])
        return arrayDiffIter(LCS, i, j - 1, a, b, [ insertion ] + acc)
    }
    else if i > 0 && (j == 0 || LCS[i][j - 1] < LCS[i - 1][j]) {
        let removal = Change.Removal(index: i - 1, value: a[i - 1])
        return arrayDiffIter(LCS, i - 1, j, a, b, [ removal ] + acc)
    }
    else {
        return acc
    }
}

func arrayDiff<T: Equatable>(LCS: [[UInt]], a: [T], b: [T]) -> [Change<T>] {
    return arrayDiffIter(LCS, a.count, b.count, a, b, [])
}

let before = [
    "feedbackType",
    "name",
    "phoneNumber",
    "email",
    "selectedImage",
    "comment",
]

let after = [
    "wat",
    "feedbackType",
    "restaurant",
    "name",
    "phoneNumber",
    "email",
    "comment",
]

let matrix = LCS(before, after)
let diff = arrayDiff(matrix, before, after)

for change in diff {
    println(change.description)
}

swift 混合Luhn算法

混合Luhn算法

gistfile1.swift
func isLuhnValid(number: String) -> Bool {
    let asciiOffset: UInt8 = 48
    let digits = Array(number.utf8).reverse().map{$0 - asciiOffset}

    let convert: (UInt8) -> (UInt8) = {
        let n = $0 * 2
        return n > 9 ? n - 9 : n
    }

    var sum: UInt8 = 0
    for (index, digit) in enumerate(digits) {
        if index & 1 == 1 {
            sum += convert(digit)
        } else {
            sum += digit
        }
    }
    return sum % 10 == 0
}

swift 功能Luhn算法

功能Luhn算法

gistfile1.swift
func isLuhnValid(number: String) -> Bool {
    let asciiOffset: UInt8 = 48
    let convert: (UInt8) -> (UInt8) = {
        let n = $0 * 2
        return n > 9 ? n - 9 : n
    }
    let digits = Array(number.utf8).reverse().map{$0 - asciiOffset}
    let indices = Array(0..digits.count)
    let evens = indices.filter{$0 & 1 == 0}.map{digits[$0]}
    let odds = indices.filter{$0 & 1 == 1}.map{digits[$0]}.map(convert)
    let sum = (evens + odds).reduce(0, +)
    return sum % 10 == 0
}