Encode Emoji to string - Stack Overflow
文章推薦指數: 80 %
128520 is the unicode scalar value of "😈": let text = "😈😀" let encoded = text.unicodeScalars.map { "" + String($0.value) + ";" }. Home Public Questions Tags Users Collectives ExploreCollectives FindaJob Jobs Companies Teams StackOverflowforTeams –Collaborateandshareknowledgewithaprivategroup. CreateafreeTeam WhatisTeams? Teams CreatefreeTeam CollectivesonStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore EncodeEmojitostring AskQuestion Asked 5years,4monthsago Active 4years,11monthsago Viewed 2ktimes 2 Iwanttoencodethisemoji😈tostring: Ihavetriedlikethis: letdata=self.comment.dataUsingEncoding(NSNonLossyASCIIStringEncoding,allowLossyConversion:true) ifletdata=data{ letemojiString=NSString(data:data,encoding:NSUTF8StringEncoding)as!String self.comment=emojiString } butitdoesn'twork. Iwanttoencodelike😈,not\ud83d\ude08 Sohowtodothis? iosswiftemoji Share Improvethisquestion Follow editedDec29'16at21:32 halfer 18.9k1616goldbadges8181silverbadges167167bronzebadges askedJul21'16at8:56 KhuongKhuong 10.2k1111goldbadges7171silverbadges107107bronzebadges Addacomment | 1Answer 1 Active Oldest Votes 4 128520istheunicodescalarvalueof"😈": lettext="😈😀" letencoded=text.unicodeScalars.map{ ""+String($0.value)+";" }.joinWithSeparator("") print(encoded)//😈😀 Share Improvethisanswer Follow editedJul21'16at9:43 answeredJul21'16at9:03 MartinRMartinR 502k8282goldbadges11611161silverbadges12811281bronzebadges 3 Thishelpsme.Thanksalot@MartinR😈. – Khuong Jul21'16at9:09 itshouldbeletunicode=text.unicodeScalars.map({""+String($0.value)}).joinWithSeparator(",")togetexpectedstring:D – Duyen-Hoa Jul21'16at9:29 @Hoa:OPsaid:"Iwanttoencodelike😈"andthatisthesyntaxofXML"characterentities".Butanyway,itshouldbeeasytoadapttheexamplecodetotheconcreteneeds. – MartinR Jul21'16at9:41 Addacomment | YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggediosswiftemojioraskyourownquestion. TheOverflowBlog Podcast398:Feelinginsecureaboutcode’ssecurity Newdata:Whatdeveloperslookforinfuturejobopportunities FeaturedonMeta Reducingtheweightofourfooter NewresponsiveActivitypage Communityinputneeded:Therulesforcollectivesarticles Related 1754 HowcanImakeaUITextFieldmoveupwhenthekeyboardispresent-onstartingtoedit? 572 ConvertUTF-8encodedNSDatatoNSString 884 HowtocheckiOSversion? 1447 Passingdatabetweenviewcontrollers 252 ConvertbetweenUIImageandBase64string 473 Loading/DownloadingimagefromURLonSwift 740 Xcode6:Keyboarddoesnotshowupinsimulator 348 Swift-encodeURL 565 Whyareemojicharacterslike👩👩👧👦treatedsostrangelyinSwiftstrings? 7 SwiftEncode/decodeemojis HotNetworkQuestions WhyisthesnowlinehigherintheHimalayasthanontheequator? Howtomakewhippedcreamjustlikeinacanister? Aresomeprotonsmoremassivethanothersduetospinningatadifferentrateorbeinginamoreexcitedstate? Repetitionoforbitalstructureonmanyscales-whatisitcalled? Helpmefindthetitleofasci-fiapocalypticmoviefollowingabrother-sisterduo,butthesisterisdifferentsomehow Whyarealltrajectoriesinspaceaconicsections? AreILSapproachestaughtaspartofinstrumentrating? Isbioluminescencemetabolicallyexpensive? RemoveUnwantedshadowingwithLineIntegralConvolutionPlot Howismomentumconservedindiffraction? “Letforeach𝑖”vs.“Foreach𝑖let” Gasrangeclicksbutdoesnotignite Helpindeterminingthefeaturesofafictionalplanet Whataretheconsequencesofgettingapositivedrugresultwhenyourbagsareswabbedattheairport? Whatisthenameofthetoolthattheguyinthisvideoisusingtolevelupthemudonceiling? Howisthis.mp4file596523hourslong? Isitoktoshareapaperacceptedforpublicationwithasingleperson? Extremedropsinharddiskperformance HowclosearetopBridgeplayerstoperfectplay? Approximatesizeofthe"hut"objectobservedfromtheYutamoonrover? Helpwithtitleofbookaboutcatlikepeople Explanationsforthreecluesinacrypticcrossword CanIconverta1x9speedbicycletosinglespeedbyputting9identicalcogsintocassette? HowmuchdutywillIhavetopayimporting72bottlesofwinefromItalytoUK morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-swift Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1Convert Emoji Characters in Unicode String to equivalent ...
Test emoji ? As we see, this string has an emoji icon, technically a unicode character, whose cod...
- 2Emoji List, v14.0 - Unicode
This chart provides a list of the Unicode emoji characters and sequences, with single image and ....
- 3safx/Emoji-Swift: String extension converting to and ... - GitHub
String extension converting to and from emoji character and Emoji-One - GitHub - safx/Emoji-Swift...
- 4Encode Emoji to string - Stack Overflow
128520 is the unicode scalar value of "😈": let text = "😈😀" let encoded = text.unicodeScalars.map ...
- 5Understanding Swift Strings, Emoji, Characters, and Scalars
By using emoji and observing the way Swift handles them, we're going to dive into the topic. Lets...