convert txt utf-8 to ansi - PowerShell - Spiceworks Community

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

I have a system generation csv files but as UTF-8. I want a way to automatically convert the files in ANSI for use in a different system. Home News&Insights News&InsightsHome Innovation ITCareers&Skills Cloud CyberSecurity FutureofWork AllCategories Marketing HR Finance Community Askquestion CommunityHome SpiceworksOriginals Cloud Collaboration Networking WaterCooler Windows Allforums How-Tos Scripts Vendors Meetups Reviews OnlineEvents Login Join Login Join Home Programming PowerShell converttxtutf-8toansi Postedbydidierodayo Solved PowerShell IhaveasystemgenerationcsvfilesbutasUTF-8.IwantawaytoautomaticallyconvertthefilesinANSIforuseinadifferentsystem.anywaytoschedulethisusingwindowstaskandpowershellorbatfile?Source: C:\tempDestination:C:\convertedFilename:namesexport Spice(2) Reply(2) flagReport didierodayo Thispersonisaverifiedprofessional. Verifyyouraccount toenableITpeerstoseethatyouareaprofessional. anaheim check BestAnswer francishagyard2 Thispersonisaverifiedprofessional. Verifyyouraccount toenableITpeerstoseethatyouareaprofessional. thaipepper PowerShellExpert check 195 BestAnswers thumb_up 347 HelpfulVotes checkBestAnswer I'mafraidyou'llhavetobemorespecificaboutwhichsystemyouwanttousethefileon,asANSIencodingdoesn'treallyexistitjustreferstothedefaultcodepageoftheOS(read:here)AsanexampleforASCIIyoucandoitlikethis: Powershell Get-Content-Path"C:\Temp\SourceFile.txt"|Out-File-FilePath"C:\Converted\DestFile.txt"-Encodingascii Ifyouwanttoseeotheravailablechracterencodingoptionsusethis: Powershell Get-HelpOut-File-ParameterEncoding Spice(4) flagReport 2foundthishelpful thumb_up thumb_down ViewBestAnswerinrepliesbelow 2Replies francishagyard2 Thispersonisaverifiedprofessional. Verifyyouraccount toenableITpeerstoseethatyouareaprofessional. thaipepper PowerShellExpert check 195 BestAnswers thumb_up 347 HelpfulVotes checkBestAnswer I'mafraidyou'llhavetobemorespecificaboutwhichsystemyouwanttousethefileon,asANSIencodingdoesn'treallyexistitjustreferstothedefaultcodepageoftheOS(read:here)AsanexampleforASCIIyoucandoitlikethis: Powershell Get-Content-Path"C:\Temp\SourceFile.txt"|Out-File-FilePath"C:\Converted\DestFile.txt"-Encodingascii Ifyouwanttoseeotheravailablechracterencodingoptionsusethis: Powershell Get-HelpOut-File-ParameterEncoding Spice(4) flagReport 2foundthishelpful thumb_up thumb_down user930587 Newcontributor pimiento Get-ContentmightbenotoptimalforconvertingtexttoUTF-8asithandles theinputfilelinebylineandmaycausechangingthelineending(for example,ifyoumovetextfilesbetweenUnixandWindowssystems).Duetothis behavior,Get-Contentisnotthebestchoiceaswell,ifperformance matters. Youcansolvethisproblemby usingtheRAWswitchwithGet-Contentasdescribedinthenextsection.  Orevenmoresimply,usetheRawswitchasdescribedheretoavoidthat overheadandreadthetextinasingleblock:  Get-Content$inFile-Raw Get-ContentC:\fso\MyFile.txt-Raw  Usingthe–RawparameterwithGet-Contentforces WindowsPowerShelltoignorenewlinecharactersandend-of-linereturns,and instead,returnthecontentsofthefileasonestring.  CorrectedCommand: Get-Content -Raw-EncodingOem|Out-File -Encodingutf8 flagReport Wasthisposthelpful? thumb_up thumb_down lock Thistopichasbeenlockedbyanadministratorandisnolongeropenforcommenting. Tocontinuethisdiscussion,pleaseaskanewquestion. Readthesenext... TechTeamBuilding/IceBreakersCollaborationIliketostartourteammeetingsoffwithanicebreakerorteambuildingexercise.Itgetsustalking,workingtogether,wegettoknoweachotherandIliketothinktheyarefun/funnyactivities.InthepastI'vedone:https://www.csap.org/fall_meeting... HTMLblockonEmail-YayorNaySecurityJustcuriousareyouguysblockingexternalemailswithHTML/HTMattachements.Theonlyissueappearstobeattimes,iPhoneorOSXmailclientsthattendtoinserta.htmlintheemailreplyfromwhatIhaveseen.Butotherthanthat,withatleast50%...Ridiculousplacesthatusersstorepasswords?SecurityIt'sCybersecurityAwarenessMonthandIimaginethisisarelevantquestionthatplagueseveryITprofessionalatonepointoranother,wheredoemployeesstoretheirpasswords? Irecallbeinginanoffice(beforeSpiceworks,ofcourse)andwalkingar...PublishPowerBItonon-licensedusersSoftwareI'mtryingtogetmyheadaroundhowtopublishareport(actuallyadashboard)tootherstaff.ThisStackOverflowquestionincludesthisanswerwhich(amongstotherthings)suggestsbuyingPremium:So,wegotmeaPremiumlicense.However,whenIshareda...HowdoyouhandleAD's"duplicatename"limitation?WindowsIrecentlyranintothelimitationinADthatpreventsauserinthesameOUfromhavingthesameFullNameasanotheruser.ThisisaverypoordesigndecisionIMHO.Peoplehavethesamename.Irecentlyranacrossthisproblemwithanemployee.Theshort...



請為這篇文章評分?