How do I convert an ANSI encoded file to UTF-8 with ...
文章推薦指數: 80 %
Try Settings -> Preferences -> New document -> Encoding -> choose UTF-8 without BOM, and check Apply to opened ANSI files . notepad++ UTF-8 ... 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 HowdoIconvertanANSIencodedfiletoUTF-8withNotepad++?[closed] AskQuestion Asked 11years,1monthago Modified 2years,5monthsago Viewed 289ktimes 80 Closed.Thisquestionisoff-topic.Itisnotcurrentlyacceptinganswers. Wanttoimprovethisquestion?Updatethequestionsoit'son-topicforStackOverflow. Closed9yearsago. Improvethisquestion Ihaveawebsite,andIcansendmyTurkishcharacterswithjQueryinFirefox,butInternetExplorerdoesn'tsendmyTurkishcharacters. Ilookedatmysourcefileinnotepad,andthisfile'scodepageisANSI. WhenIconvertittoUTF-8withoutBOMandclosethefile,thefileisagainANSIwhenIreopen. HowcanIconvertmyfilefromANSItoUTF-8? utf-8notepad++ Share Improvethisquestion Follow editedMay27,2017at13:47 Aurora0001 12.5k55goldbadges4949silverbadges5151bronzebadges askedAug31,2011at11:05 KeremBekmanKeremBekman 1,26122goldbadges1313silverbadges2424bronzebadges 2 1 YoucanusethetoolIwroteforthat,Ialsosufferedfromsameproblemandmademyownwayout.github.com/srcnalt/ANSI-to-UTF8 – Sarge Feb3,2014at8:33 Iagreethat–inastrictsense–thisquestionisnoton-topicforStackOverflow.~*~Butit'sverymuchON-topicforSuperUser.Aftermorethan9years(!),itstillhasn'tbeenmigratedtoSuperUser.Suchapity. – Henke Sep28at11:20 Addacomment | 3Answers 3 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 77 Regardingthispart: WhenIconvertittoUTF-8withoutbomandclosefile,thefileisagainANSIwhenIreopen. TheeasiestsolutionistoavoidtheproblementirelybyproperlyconfiguringNotepad++. TrySettings->Preferences->Newdocument->Encoding->chooseUTF-8withoutBOM,andcheckApplytoopenedANSIfiles. ThatwayalltheopenedANSIfileswillbetreatedasUTF-8withoutBOM. Forexplanationwhat'sgoingon,readthecommentsbelowthisanswer. TofullylearnaboutUnicodeandUTF-8,readthisexcellentarticlefromJoelSpolsky. Share Improvethisanswer Follow editedApr17,2020at17:42 answeredSep14,2011at21:54 jakub.gjakub.g 35.8k1010goldbadges8989silverbadges126126bronzebadges 7 Thathelpedmealot.Thanks.Idonotunderstandthebehaviorthough.BecauseIopenanexistingfileandnotanewone. – Dr.ManuelKuehner Aug8,2014at9:34 2 TheApplytoopenedANSIfilesisrelevantinyoursituation:whenyouhaveafilethatcontainsonlyplainASCIIcharacters(withoutaccentsetc.),andyoudon'thaveBOMatthebeginningofthefile,thentheeditorbydefaulttreatsitasanANSIfile,becausethere'snothinginthisfiletoindicatethatyoumightwanttotreatisanUTF-8file.Howeverwhenyouadd,say,ÖandsaveitasUTF-8w/oBOM,eventhoughthere'snoBOMatthebeginningofthefile,fromthepresenceoftwo-bytecombobehindÖ(0xC396inthiscase)theeditorlearns"thishastobeUTF-8". – jakub.g Aug8,2014at12:45 2 Inotherwords,whenyousaveANSIplainfileasUTF-8,theoutputisidenticalasyouweretosaveitasANSI.YouhavetotelltheeditortotreatitasUTF-8whenyouopenit.ForthefiletobeUTF-8,iteitherhastostartwithaBOM,orcontaincertaintwo-bytessequences.ThebehavioroftheeditorwhenyouinputÖinanANSIfileisconfigurationdependent. – jakub.g Aug8,2014at12:53 1 AFAIKtheonlyencodingthatyoucanenforcefromtheeditoronreadtime,byputtingcertaincharactersinthefile,isUTF-8withBOM. – jakub.g Apr25,2016at15:14 1 @SanderdeJongworksformewith7.8.532-bit-Ipostedanimage – jakub.g Apr17,2020at17:43 | Show2morecomments 45 Maybethisisnottheansweryouneeded,butIencounteredsimilarproblem,soIdecidedtoputithere. Ineededtoconvert500xmlfilestoUTF8viaNotepad++.WhyNotepad++?WhenIusedtheoption"EncodeinUTF8"(manyotherconvertersusethesamelogic)itmessedupallspecialcharacters,soIhadtouse"ConverttoUTF8"explicitly. HeresomesimplestepstoconvertmultiplefilesviaNotepad++withoutmessingupwithspecialcharacters(forex.diacriticalmarks). RunNotepad++andthenopenmenuPlugins->PluginManager->Show PluginManager InstallPythonScript.Whenpluginisinstalled,restartthe application. ChoosemenuPlugins->PythonScript->Newscript. Chooseitsname,andthenpastthefollowingcode: convertToUTF8.py importos importsys fromNppimportnotepad#importitfirst! filePathSrc="C:\\Users\\"#Pathtothefolderwithfilestoconvert forroot,dirs,filesinos.walk(filePathSrc): forfninfiles: iffn[-4:]=='.xml':#Specifytypeofthefiles notepad.open(root+"\\"+fn) notepad.runMenuCommand("Encoding","ConverttoUTF-8") #notepad.save() #ifyoutrytosave/replacethefile,anannoyingconfirmationwindowwouldpopup. notepad.saveAs("{}{}".format(fn[:-4],'_utf8.xml')) notepad.close() Afterall,runthescript Share Improvethisanswer Follow editedFeb21,2016at9:42 answeredJun22,2013at10:26 JunMurakamiJunMurakami 80511goldbadge99silverbadges1717bronzebadges 8 2 Greatsolution.SinceIusenotepad++localizationI'vehadtotranslate'Encoding'and'ConverttoUTF-8'options,weird. – Piotr Jun29,2013at14:41 Iwonderhowtorunthepythonscript?Irunitinacommandlineanditsaysthatnotepadcannotbefound. – flexwang May27,2014at3:08 2 Hiflexwang,youshouldrunitfromNotepad++ – JunMurakami May27,2014at8:47 IgoterrormeassagebecauseoftheChinesecharacters.dropbox.com/s/f2efnzt9cd2i5or/… – ZhangLongQI May31,2014at8:06 2 doesntworkanymore:( – Phil Feb20,2016at17:14 | Show3morecomments 16 Ifyoudon'thavenon-ASCIIcharacters(codepoints128andabove)inyourfile,UTF-8withoutBOMisthesameasASCII,byteforbyte-soNotepad++willguesswrong. WhatyouneedtodoistospecifythecharacterencodingwhenservingtheAJAXresponse-e.g.withPHP,you'ddothis: header('Content-Type:application/json;charset=utf-8'); TheimportantpartistospecifythecharsetwitheveryJSresponse-elseIEwillfallbacktouser'ssystemdefaultencoding,whichiswrongmostofthetime. Share Improvethisanswer Follow answeredAug31,2011at11:12 PiskvorleftthebuildingPiskvorleftthebuilding 90.1k4545goldbadges178178silverbadges222222bronzebadges 2 Whyisn'tthistheacceptedanswer?It'stheonlyanswerthatexplainswhatishappening,andwhattherealsolutiontothequestionis. – MáthéEndre-Botond Oct3,2016at11:16 soNotepad++willguesswrong–Maybejustamatterofwording,butIwouldn'tsaythatNotepad++guessesitwrong.I'drathersaythat–forafilecontainingonlyASCIIcharacters–encodingasANSIorUTF-8isequallycorrect.AndtheonlywaytomakeNotepad++chooseUTF-8overANSIistomakeUTF-8thedefaultencoding(forpureASCIIfiles).Thisanswershowshowtodojustthat. – Henke Sep28at12:44 Addacomment | Nottheansweryou'relookingfor?Browseotherquestionstaggedutf-8notepad++oraskyourownquestion. TheOverflowBlog HowtoearnamillionreputationonStackOverflow:beofservicetoothers Therightwaytojobhop(Ep.495) FeaturedonMeta BookmarkshaveevolvedintoSaves Inboximprovements:markingnotificationsasread/unread,andafiltered... Revieweroverboard!Orarequesttoimprovetheonboardingguidancefornew... CollectivesUpdate:RecognizedMembers,Articles,andGitLab Shouldweburninatethe[script]tag? Linked 136 EnablebinarymodewhilerestoringaDatabasefromanSQLdump 7 ConvertfromANSItoUTF-8 6 UnicodeDecodeErroronpython3 4 HowdoIgetridofthischaracter? 3 syntaxerrornearunexpectedtoken`fi'whilecheckingnoofargumentspassed 2 ???QuestionsMarksinMetaTagsinSocialWebCrawlersforAngularJSapplicationusingPrerender.io 0 array_filterdoesn'tseemstoworkforwordshavingapostropheanddash 0 SonarQubeshowsWarn-Roslynencodingis'UTF-8'forC-Sharp 1 jQueryTablesorterParserforHeightandFractions 0 HowtowritebothChinesecharactersandEnglishcharactersintoafile(Python3)? Seemorelinkedquestions Related 1228 ConverttabstospacesinNotepad++ 1239 HowtoreformatJSONinNotepad++? 3 HowtoavoidinadvertentencodingofUTF-8filesasASCII/ANSI? 1987 HowdoIformatXMLinNotepad++? 214 HowcanIoutputaUTF-8CSVinPHPthatExcelwillreadproperly? 1 PHPAnsitoUTF-8 704 HowToAuto-Format/IndentXML/HTMLinNotepad++ 29 HowcanImakeNotepadtosavetextinUTF-8withouttheBOM? 101 ConvertUTF-8withBOMtoUTF-8withnoBOMinPython 14 Notepad++converttoUTF-8multiplefiles HotNetworkQuestions WhydopeopleinsistonusingTikzwhentheycanusesimplerdrawingtools? Determinethelengthoftherestofamathdisplaylineformultlined Whenisthefirstelementintheargumentlistregardedasafunctionsymbolandwhennot? HowcanIuseWindowstocreateanOSXYosemiteUSBflashdriveinstallerfromthediskimage(.dmg)filedownloadedfromApple? Howtoremovetikznode? HowtogetridofUbuntuProadvertisementwhenupdatingapt? ArethereanyspellsotherthanWishthatcanlocateanobjectthroughleadshielding? DidMS-DOSeverdropabilitytosupportnon-IBMPCcompatiblemachines? Shouldselectedoptionsberemovedfromsingle-andmulti-selectdropdownlists? Probabilisticmethodsforundecidableproblem Howtosimplifyapurefunction? Whatisthebestwaytocalculatetruepasswordentropyforhumancreatedpasswords? Interpretinganegativeself-evaluationofahighperformer InD&D3.5,whathappenswhenyouplopaheadbandofintellectonananimal? WherewasthisneonsignofadragondisplayedinLosAngelesinthe1990s?Isitstilltherenow? WhathadEstherdonein"TheBellJar"bySylviaPlath? Simplebikecomputer Isitcorrecttochangetheverbto"being"in"Despitenoonewashurtinthisincident…"? I2C(TWI)vsSPIEMInoiseresistance WhatisthedifferencebetweenGlidepathversusGlideslope? WhytheneedforaScienceOfficeronacargovessel? Howdoparty-listsystemsaccommodateindependentcandidates? keyless/flatkeyboard StrangeFruitfromTomatoPlant morehotquestions Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1How do I convert an ANSI encoded file to UTF-8 with ...
Try Settings -> Preferences -> New document -> Encoding -> choose UTF-8 without BOM, and check Ap...
- 2如何把純文字檔案轉換成UTF-8格式:使用Notepad++ / How ...
純文字檔案轉換成UTF-8 / Convert Text Into UTF-8 Encoding · 1. 開啟檔案/ Open File · 2. 改變編碼為UTF-8 / Convert E...
- 3Change the file encoding using Notepad++ - YouTube
- 4How do I save a Notepad file as UTF-8? - Ru-facts.com
Go to File > Save As… and choose UTF-8 under Encoding:, press Save and overwrite the existing fil...
- 5Notepad++ automatically changing files from ANSI to UTF-8
Comments · Steps to Reproduce the Issue. Pre-req: file saved in ANSI. Open file in Notepad++; Val...