Save text file in UTF-8 encoding using cmd.exe - Stack Overflow
文章推薦指數: 80 %
The default encoding for command prompt is Windows-1252. Change the code page (chcp command) to 65001 (UTF-8) first and then run your ... 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 SavetextfileinUTF-8encodingusingcmd.exe AskQuestion Asked 9years,4monthsago Modified 2years,1monthago Viewed 51ktimes 34 IsitpossibletosaveatextfileinUTF-8encodingusingWindows'commandlinecmd.exe? CurrentI'mcreatingthetextfileusingcommandredirectionoperators: C:\Windows\system32\ipconfig/all>>output.log Istartwith>togetanewfileandthenIuse>>toappendmoreinformation. windowsencodingutf-8cmd Share Improvethisquestion Follow editedSep10,2020at6:49 MartinPrikryl 174k5151goldbadges431431silverbadges890890bronzebadges askedMay16,2013at22:51 user2333346user2333346 1,04344goldbadges1919silverbadges4040bronzebadges 4 3 IfyouareusingI/Oredirectionoperators,thenit'snotuptotheshellwhatthecharacterencodingofthedatais.It'suptothecommandwhoseoutputisredirected.IfthatcommandproducesvalidUTF-8,that'swhatwillendupinthefile. – Celada May17,2013at0:29 Imoipconfiguses"Unicode". – Endoro May17,2013at4:36 Itdoesn't.Likeallconsolemodeprograms,itgeneratestextinthedefault8-bitcodepageencodingthat'sactivefortheconsole.Whichyouchangetoutf-8withchcp65001.Youstillwon'tgetaBOM. – HansPassant May17,2013at10:03 2 cmd/u/c"ipconfig/all">>output.log??? – npocmaka May17,2013at18:46 Addacomment | 2Answers 2 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 47 ThedefaultencodingforcommandpromptisWindows-1252.Changethecodepage(chcpcommand)to65001(UTF-8)firstandthenrunyourcommand. chcp65001 C:\Windows\system32\ipconfig/all>>output.log Changeitbacktodefaultwhendone. chcp1252 Share Improvethisanswer Follow editedJun15,2015at0:33 SLaks 848k174174goldbadges18771877silverbadges19451945bronzebadges answeredAug6,2013at18:39 rchnrchn 93311goldbadge88silverbadges1010bronzebadges 2 Herearesomeothercodethatmaybeuseful – LordST Oct31,2015at21:55 1252mightnotbethedefaultcodepage.TheOEMcodepageisthedefault. – Anders Feb11,2017at14:55 Addacomment | 4 Astheexistinganswersays,inabatchfile,youcanusethechcpcommand chcp65001>nul some_command>file Butifyouareusingthecmd.exefromitscommandline,e.g.toexecuteauser-definedcommand,youcanusethissyntax: cmd.exe/cchcp65001>nul&cmd.exe/csome_command>file Share Improvethisanswer Follow editedMar4,2018at13:21 answeredOct11,2016at13:47 MartinPrikrylMartinPrikryl 174k5151goldbadges431431silverbadges890890bronzebadges 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?Browseotherquestionstaggedwindowsencodingutf-8cmdoraskyourownquestion. TheOverflowBlog HowtoearnamillionreputationonStackOverflow:beofservicetoothers Therightwaytojobhop(Ep.495) FeaturedonMeta BookmarkshaveevolvedintoSaves Inboximprovements:markingnotificationsasread/unread,andafiltered... Revieweroverboard!Orarequesttoimprovetheonboardingguidancefornew... CollectivesUpdate:RecognizedMembers,Articles,andGitLab Shouldweburninatethe[script]tag? Linked 0 PerlorPowershellhowtoconvertfromUCS-2littleendiantoutf-8ordoinlineonelinersearchreplaceregexonUCS-2file 0 WhydoesUTF-8encodingnotworkforspecialcharacterinprocessinputstream? -1 Folderlistanditssizes 0 Can'tshowcertainUTF-8charactersinandroidwebview Related 597 Bestwaytoconverttextfilesbetweencharactersets? 609 HowdoIgetcurrentdate/timeontheWindowscommandlineinasuitableformatforusageinafile/foldername? 327 DetectencodingandmakeeverythingUTF-8 291 Whatencoding/codepageiscmd.exeusing? 122 HowdoesUTF-8"variable-widthencoding"work? 286 GetencodingofafileinWindows 585 WhydoesmodernPerlavoidUTF-8bydefault? 1 Symfony3Errorencodingutf-8 1 HowtosavetextfilewithUTF-8encodinginjava? HotNetworkQuestions Howdoyoucalculatethetimeuntilthesteady-stateofadrug? Whyare"eat"and"drink"differentwordsinlanguages? Sciencefictionbook/novelaboutaliensinhumansbodies Wouldextractinghydrogenfromthesunlessenitslifespan? IsdocumentingabigprojectwithUMLDiagramsneeded,goodtohaveorevennotpossible? Whataretheargumentsforrevengeandretribution? Idon'tunderstandif"per"meaningexactamountforeachunitordoesitmean"onaverage" ElectronicCircuitsforSafeInitiationofPyrotechnics? Whatisthebestwaytocalculatetruepasswordentropyforhumancreatedpasswords? Howdocucumbershappen?Whatdoes"verypoorlypollinatedcucumber"meanexactly?Howcanpollinationbe"uneven"? Howcanmyaliensymbiotesidentifyeachother? Canyoufindit? HowtogetridofUbuntuProadvertisementwhenupdatingapt? I2C(TWI)vsSPIEMInoiseresistance DidMS-DOSeverdropabilitytosupportnon-IBMPCcompatiblemachines? IfthedrowshadowbladeusesShadowSwordasarangedattack,doesitthrowasword(thatitthenhastoretrievebeforeusingitagain)? UnderstandingElectricFieldsLinesandhowtheyshow‘like’chargesrepelling Howdouncomputablenumbersrelatetouncomputablefunctions? keyless/flatkeyboard DoestheDemocraticPartyofficiallysupportrepealingtheSecondAmendment? WillIgetdeniedentryafterIremovedavisasticker?Ismypassportdamaged? LaTeX2(e)vsLaTeX3 WhyareRussiancombatantsinUkraineconsideredsoldiersratherthanterrorists? Howtotellifmybikehasanaluminumframe morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1Save text file in UTF-8 encoding using cmd.exe - Stack Overflow
The default encoding for command prompt is Windows-1252. Change the code page (chcp command) to 6...
- 2cmd命令行導出的txt文本文檔編碼格式轉換 - 台部落
如下圖,在原目錄會生成新的txt,編碼格式utf-8,完成轉碼。 ... 在cmd中輸入PowerShell -Command "& {get-content 1.txt -encoding u...
- 3Write CMD output to file as UTF-8 - Macro Scheduler Forums
/s /b /o:gn /A-D > "%FILE_ROOT_PATH%\results.txt" The first part is to set the output format to U...
- 4Converting text file to UTF-8 on Windows command prompt
I need to convert a text file to utf-8 format via windows command prompt. You can easily do this ...
- 5windows - Save text file in UTF-8 encoding using cmd.exe
The default encoding for command prompt is Windows-1252. Change the code page (chcp command) to 6...