Whats going on with this byte array? - Stack Overflow
文章推薦指數: 80 %
When that character gets encoded back to UTF-8, this results in the byte sequence EF BF BD . You cannot construct the original byte value from ... Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams Whatsgoingonwiththisbytearray? AskQuestion Asked 11years,3monthsago Modified 3monthsago Viewed 13ktimes 16 Ihaveabytearray: 0001000000128100000100C80000000000085C9F4FA50945D4CE ItisreadviaStreamReaderusingUTF8encoding //NoteIcan'tchangethiscode,tomanycomponentdependentonit. using(StreamReaderstreamReader= newStreamReader(responseStream,Encoding.UTF8,false)) { stringstreamData=streamReader.ReadToEnd(); if(requestData.Callback!=null) { requestData.Callback(response,streamData); } } WhenthatfunctionrunsIgetthefollowingreturnedtome(iconvertedtoabytearray) 000100000012EFBFBD00000100EFBFBD0000000000085CEFBFBD4FEFBFBD0945EFBFBD SomehowIneedtotakewhatsreturnedtomeandgetitbacktotherightencodingandtherightbytearray,butI'vetriedalot. Pleasebeaware,I'mworkingwithWP7limitedAPI. Hopefullyyouguyscanhelp. Thanks! Updateforhelp... ifIdothefollowingcode,it'salmostright,onlythingthatiswrongisthe5thtolastbytegetssplitout. byte[]writeBuf1=System.Text.Encoding.UTF8.GetBytes(data); stringbuf1string=System.Text.Encoding.BigEndianUnicode.GetString(writeBuf1,0,writeBuf1.Length); byte[]writeBuf=System.Text.Encoding.BigEndianUnicode.GetBytes(buf1string); windows-phone-7c#-4.0encodingbytearray Share Follow editedJul1,2011at4:57 John askedJul1,2011at4:22 JohnJohn 16511goldbadge11silverbadge55bronzebadges 7 Canyoushowusthecodethatiswriting/creatingthearray? – Emond Jul1,2011at4:30 Nope,it'scommingfromathirdpartyservice,that'stheexactdatathattheservicereturns...Besides,Ijustwanttogetitbacktowhatit'ssupposedtobe(asitstandsintheresponsestream) – John Jul1,2011at4:52 Iamseriouslyboggledonthisone... – John Jul1,2011at5:29 Thenhowdoyouknowinwhatencodingandbyte-orderthestreamiswrittento? – Emond Jul1,2011at5:29 Canyouattachanetworksniffer(Fiddler)toseewhatisactuallybeingtransmitted? – Emond Jul1,2011at5:31 | Show2morecomments 1Answer 1 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 36 TheoriginalbytearrayisnotencodedasUTF-8.TheStreamReaderthereforereplaceseachinvalidbytewiththereplacementcharacterU+FFFD.WhenthatcharactergetsencodedbacktoUTF-8,thisresultsinthebytesequenceEFBFBD.Youcannotconstructtheoriginalbytevaluefromthestringbecausetheinformationiscompletelylost. Share Follow editedMay28,2021at14:59 StackzOfZtuff 2,06611goldbadge2626silverbadges2222bronzebadges answeredJul1,2011at6:05 RolandIlligRolandIllig 39.7k1010goldbadges8282silverbadges118118bronzebadges 5 That'swhatIwasafraidof...Sotheonlywaytoreallynotlosethedataisfigureoutwhattheencodingisandreadlikethat?Unfortunatly,forsomereasonIcan'tjustreadabytearray,theStreamrequiresastreamreadertoread... – John Jul1,2011at6:18 1 Yes,andwhenyouareindoubt,useISO-8859-1,soyouwillgetasimple1:1mappingfrombytestocharacters.Justforcuriosity:Whywouldanyonewanttoreadabytestreamlikethis(whichisobviouslynon-characterdata)asacharacterstream? – RolandIllig Jul1,2011at6:24 Can'tyouaskthesourceofthestreamforaspecification? – Emond Jul1,2011at6:52 Everythingis(andhasbeen)characterdataexceptforthisonenewpart.Eitherway,Ijustaddedsomeoverridestogettheactualbyte[]optionallyandallseemswellwiththeISO-8859-1encoding.Thanks! – John Jul1,2011at13:34 1 Wow,holyshit,sothesebytesareprettygoodmarkersofincorrectencodingbeingused! – mikenelson Dec14,2015at18:55 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?Browseotherquestionstaggedwindows-phone-7c#-4.0encodingbytearrayoraskyourownquestion. TheOverflowBlog HowtoearnamillionreputationonStackOverflow:beofservicetoothers Therightwaytojobhop(Ep.495) FeaturedonMeta BookmarkshaveevolvedintoSaves Inboximprovements:markingnotificationsasread/unread,andafiltered... Revieweroverboard!Orarequesttoimprovetheonboardingguidancefornew... CollectivesUpdate:RecognizedMembers,Articles,andGitLab Shouldweburninatethe[script]tag? Linked 9 WeirdcharactersinURL 3 HandleHttpUploadZipfileinGolang 1 mysqllinebreaksformatting 1 Javaencoding-corruptedFrenchcharacters -2 LoadingPhototoLDAPViaMuleSoftJavamodule Related 966 ConvertInputStreamtobytearrayinJava 452 BestwaytoreadalargefileintoabytearrayinC#? 214 hexadecimalstringtobytearrayinpython 0 Storebinarydatastringintobytearrayusingc# 777 HowtoconvertabytearraytoahexstringinJava? 175 HowcanItransformstringtoUTF-8inC#? 888 ConvertingstringtobytearrayinC# 1 What'sthecorrectwaytocountthebytesneededforaUTF8conversion? HotNetworkQuestions StandardCoverflow-safearithmeticfunctions WhydidGodprohibitwearingofgarmentsofdifferentmaterialsinLeviticus19:19? CanIuseaspritesheetfromanexistingvideogameformypromotionalreel? DidMS-DOSeverdropabilitytosupportnon-IBMPCcompatiblemachines? MakeaCourtTranscriber Whatare"HollywoodTwin"beds? Howtoelegantlyimplementthisoneusefulobject-orientedfeatureinMathematica? Howdouncomputablenumbersrelatetouncomputablefunctions? Drawarrowfromequationtotextoutsideequation IsdocumentingabigprojectwithUMLDiagramsneeded,goodtohaveorevennotpossible? Howtotellifmybikehasanaluminumframe Howtosimplifyapurefunction? Changelinkcolorbasedinbackgroundcolor? Whatisthedefinitionofatrollinthelegalcontext? Alternativeversionsofbreathing? WhathappenswhenthequasarremnantsreachEarthin3millionyears? rename(Perl)-tryingtorenumberalistoffiles,startingatacertainvalue WhyareRussiancombatantsinUkraineconsideredsoldiersratherthanterrorists? StrangeFruitfromTomatoPlant Findanddeletepartiallyduplicatelines Whatisthebestwaytocalculatetruepasswordentropyforhumancreatedpasswords? Sciencefictionbook/novelaboutaliensinhumansbodies Whyare"eat"and"drink"differentwordsinlanguages? Doyoupayforthebreakfastinadvance? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-cs Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1Unicode/UTF-8-character table - starting from code position ...
code point, character, UTF-8 (hex.) name. U+FF00, , ef bc 80. U+FF01 ! ef bc 81, FULLWIDTH EXCLA...
- 2位元組順序記號 - 维基百科
位元組順序記號(英語:byte-order mark,BOM)是位於碼點 U+FEFF 的統一碼字符的名称。當以UTF-16 ... 它常被用來當做標示文件是以UTF-8、UTF-16或UTF-...
- 3Whats going on with this byte array? - Stack Overflow
When that character gets encoded back to UTF-8, this results in the byte sequence EF BF BD . You ...
- 4UTF-8 - 字嗨!
UTF-8是Unicode的一種可變長度的字元編碼形式。它設計來相容於ASCII,讓原本處理ASCII字元 ... 0800~FFFF, 3, 1110xxxx (E0-EF), 10xxxxx...
- 5UTF-8字符「EF BF BD」-备胎_mob604756f87695的技术博客
UTF-8字符「EF BF BD」-备胎,在众多的utf-8码点值中,除了ascii,你还应该记住「EFBFBD」,因为它是很多编程语言以及库中的备胎,即无效的码点值在 ...