Php function to decode UTF-16 Unicode to emoji - Stack ...

文章推薦指數: 80 %
投票人數:10人

this may be one way to work around your %u syntax $emoji = '%uD83D%uDE0B'; print 'This is my emoji: '. json_decode('"' . str_replace('%', '\\', $emoji) . 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 PhpfunctiontodecodeUTF-16Unicodetoemoji AskQuestion Asked 3years,10monthsago Active 3years,10monthsago Viewed 2ktimes 0 Ihavetriedmanycodesnippetshereatstackoverflowwithoutsuccess. Iamlookingforaphpfunctiontoconvert- "Thisisasmiley"%uD83D%uDE0B" to "Thisisasmiley😋" HereisaworkingexampleofwhatIamtryingtoachieve. http://www.online-toolz.com/tools/text-unicode-entities-convertor.php Under:Decode/UnescapeUnicodeEntities phpunicode Share Follow editedJan17'18at15:34 ArshDhillon askedJan17'18at15:17 ArshDhillonArshDhillon 9188bronzebadges 3 1 Whatformatis%u....supposedtobe?That'snotoneofthestandardcharacterescapingformatsIrecognise. – deceze ♦ Jan17'18at15:22 Havealookatfileformat.info/info/unicode/char/1f60b/index.htmIcantfindtheformatyou'retalkingabout. – Scriptman Jan17'18at15:24 yesitis,Ineedafunctiontoconvert%uD83D%uDE0B>D83DDE0B>😋 – ArshDhillon Jan17'18at15:25 Addacomment  |  1Answer 1 Active Oldest Votes 3 thismaybeonewaytoworkaroundyour%usyntax $emoji='%uD83D%uDE0B'; print'Thisismyemoji:'.json_decode('"'.str_replace('%','\\',$emoji).'"'); baseonPrintUnicodecharactersPHP Share Follow answeredJan17'18at15:39 arhakarhak 2,35011goldbadge2323silverbadges3737bronzebadges 2 Thanks,thisisexactlywhatIwant,Howcanihavetheoutputinvariable($str)insteadofprint? – ArshDhillon Jan17'18at15:55 changeprint'...';to$str='...';instead – arhak Jan18'18at2:33 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?Browseotherquestionstaggedphpunicodeoraskyourownquestion. TheOverflowBlog Podcast395:Whoisbuildingcloudsfortheindependentdeveloper? Explodingturkeysandhownottothawyourfrozenbird:Topturkeyquestions... FeaturedonMeta Nowlive:Afullyresponsiveprofile Reducingtheweightofourfooter TwoBornottwoB-Farewell,BoltClockandBhargav! Linked 12 PrintUnicodecharactersPHP Related 2773 HowcanIpreventSQLinjectioninPHP? 1286 UTF-8allthewaythrough 2820 DeletinganelementfromanarrayinPHP 912 What'sthedifferencebetweenUTF-8andUTF-8withoutBOM? 4827 Reference—WhatdoesthissymbolmeaninPHP? 2169 HowdoesPHP'foreach'actuallywork? 2630 Whyshouldn'tIusemysql_*functionsinPHP? 1391 WhyisexecutingJavacodeincommentswithcertainUnicodecharactersallowed? 3 UnicodeEncodeError:'utf-8'codeccan'tencodecharactersinposition0-15:surrogatesnotallowed 0 Decode/UnescapeUnicodeEntitiesinpython HotNetworkQuestions HowtojustifysmallHomininsnotbeingconqueredby(anatomicallymodern)Humans? PutoldSSDwithWin10InstalledintolaptopwithLinuxandbootWindows? Does来mean"bring"? IsitlegalintheUStoleaveaguninthehandsofaminorwithoutoversight? HowcanIfitaglasscooktophoodintoaspacethat'stootight? WhydoesHebrews3:1callJesusanapostle? Islookingforplaintextstringsonanencrypteddiskagoodtest? Skippingcertainnumbersinalist Candefrostingvacuum-packedfishinitspackagingcausebotulism? Viewsversusafunctionforgettingthetoprecordsofatable? Dostateswithinfiniteaverageenergymakesense? Commenttraduire« HoweverlittleImayremember »? In-TransitWaitingAreainUSAAirports? Isitoktofeedmycatonechickenliverdaily? Whyisthecurrententeringaconductorthesameastheoneexitingit? DoesaserverneedaGPU? AnecdoteinWeinberger'sPsychologyofComputerProgramming:isitARPANET? Howcananoceanofseawaterbehavelikehoneywithoutchangingthechemistry? Couldsiliconbasedlifeformseatcarbonbasedfood Whydidn'ttheEnterprise-DsendaprobetolookforPicard? Youngadulttime-travellingbookwiththetag-line"whatifyoucouldslipinandoutoftime" WhatshouldIdoideallytorechargeduringaPhD? Algebraictopologyandhomotopytheorywithsimplicialsetsinsteadoftopologicalspaces IdentifyingMotherboardandCPU morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-php Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?