File encoding not preserved after saving in Notepad++

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

Go in the menu Settings -> Preference -> New document/ Default Directory. In the suck section Encoding, check UTF-8 without BOM and check Apply ... SuperUserisaquestionandanswersiteforcomputerenthusiastsandpowerusers.Itonlytakesaminutetosignup. Signuptojointhiscommunity Anybodycanaskaquestion Anybodycananswer Thebestanswersarevotedupandrisetothetop Home Public Questions Tags Users Companies Unanswered Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams FileencodingnotpreservedaftersavinginNotepad++ AskQuestion Asked 10years,3monthsago Modified 2years,8monthsago Viewed 15ktimes 5 I'musingNotepad++foreditingmyPHPscripts. However,Ifoundastrangeproblem:whenchangingtheencodingfromANSItoUTF-8(withoutBOM),saving,closing,re-loading–thencheckingencoding:isstillANSI. Anyideaswhat'swrong?Italwaysworkedformeinthepast. notepad++encodingutf-8bom Share Improvethisquestion Follow editedJan30,2020at19:45 zx485 2,1521111goldbadges1616silverbadges2323bronzebadges askedJul12,2012at11:07 FuxiFuxi 77333goldbadges99silverbadges2020bronzebadges 1 Ifyouchangetheencodingthenmakesomechangebeforesaving,doesthatmakeadifference? – VinceBowdren May31,2013at9:23 Addacomment  |  3Answers 3 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 9 Thisisexpectedbehaviour. Itcanhappenthatafileissavedwithacertainencoding,butuponreopeningitinNotepad++itisdetectedwithanotherencoding.Thisisatechnicallimitationandhappensbecausesometimestheresultingfilewillnotdiffereventhoughdifferentencodingsareused.ThisismostnoticeableifthefileissavedwithoutaspecialBOM(ByteOrderMark)indicatingtheusedencoding. ANSIandUTF-8sharetheirfirst128characters(ASCII),makingthemindistinguishableifthoseareallyouuse.Withaplaintextfile,thereisnometadataindicatingtheencoding,soallNotepad++(andothereditors)candoislookatthecharacters/datainthefileandtakeaguess. IfthefilehasaBOM,NP++detectsitandknowsabouttheencoding. IfthefileisHTMLorXML,theencodingisreadfromthefirstlineofthefile. Otherwise,NP++takesaguessbetweenUCS-2LE,UCS2-BEandANSI.YoucannotmakeadifferencebetweenafileencodedinUTF-8withoutBOMandafileinANSIwithplentyofhighASCIIcharacters. http://sourceforge.net/projects/notepad-plus/forums/forum/331754/topic/3822723 Intheory,PRacicot'sanswershouldopenallANSI/UTF-8files(withoutaBOM)asUTF-8.ThisisalsorecommendedinananswertoasimilarStackOverflowquestion.Ifthisdoesn'tworkforyou,I'mnotsurewhatcanbedone.TheencodingisindicatedasANSIasUTF-8inthestatusbar,forme. Share Improvethisanswer Follow editedMay23,2017at11:33 CommunityBot 1 answeredJul12,2012at12:29 BobBob 59.5k2424goldbadges184184silverbadges209209bronzebadges 5 MakesmewonderwhyBOMisnotrecommended,whenitappearsthatusingUTF8ishighlyannoyingandeasilysubjecttoerrorwithoutit. – Jonathon Mar11,2013at3:38 1 @JonathonWisnoskiIbelieveit'sbecausetheuseofaBOMcanbreakbackwardscompatibilitywithlegacy(andother)programsexpectingASCII.Inparticular,manyscriptparsers(possiblyincludingPHP)andtheshebangonsomePOSIXsystemswouldtripup. – Bob Mar31,2013at12:35 ANSIandUTF-8arenotmoreorlessthesame-apartfromtheASCIIsubset,theyarecompletelydifferent.TryingtoreadaUTF-8file(withnon-ASCIIcharacters)asANSIwillresultingarbage,tryingtoreadanANSIfile(withnon-ASCIIcharacters)asUTF-8willmostlikelyresultindecodingerrors(butcanalsoresultingarbageinsomecases). – oefe Jul3,2015at14:30 @oefeEditedANSI=>ASCII. – Bob Jul3,2015at14:45 muchbetter! – oefe Jul3,2015at14:52 Addacomment  |  7 Youmaywanttochangethissettinginyou'renotepad++preference. GointhemenuSettings->Preference->Newdocument/DefaultDirectory. InthesucksectionEncoding,checkUTF-8withoutBOMandcheckApplytoopenedANSIfiles. BycheckingtheApplytoopenedANSIfiles,thispreferencewillalsobeapplytocurrentopeneddocumentsinnotepad++. SinceIdon'thaveenoughpointsyettopostimagehereisalinktopostimagewhereIuploadedtheimage:http://postimage.org/image/4qza0bkv9/ GoodLuckandhappyprogramming. Share Improvethisanswer Follow editedJul12,2012at12:23 answeredJul12,2012at11:53 PRacicotPRacicot 10311silverbadge55bronzebadges 0 Addacomment  |  3 YouhavetoConvertto...insteadofchangetheEncodeto...option. Youmayalsowanttochangethisoptioninthesettings,soallyournewfileswillgetcreatedwithyourchoosenencoding. Share Improvethisanswer Follow editedJul12,2012at11:47 answeredJul12,2012at11:40 ApacheApache 15.8k2323goldbadges9898silverbadges148148bronzebadges 1 1 thanksforyourcomment,alreadydidthatbutdidn'thelp.whenselecting"convertto..",saving,reloading-it'sstillANSI.ialsotriedcreatinganewfileandpasting. – Fuxi Jul12,2012at11:49 Addacomment  |  YourAnswer ThanksforcontributingananswertoSuperUser!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?Browseotherquestionstaggednotepad++encodingutf-8bomoraskyourownquestion. TheOverflowBlog HowtoearnamillionreputationonStackOverflow:beofservicetoothers Therightwaytojobhop(Ep.495) FeaturedonMeta BookmarkshaveevolvedintoSaves Inboximprovements:markingnotificationsasread/unread,andafiltered... Related 7 ForceUTF-8oneverydocumentopenedinNotepad++ 2 CreatenewfileinWinSCPwithUTF-8withoutBOMencoding 9 HowtochangeLibreOfficedefaulttextencoding? 0 utf8,utf8BOM,utf8NoBOMPowershellencoding 0 WhydoescopyingtextbetweenNotepad++filescreatefileswithdifferentbytes? 0 WindowsServer2019andFileEncoding HotNetworkQuestions MLmodellingwheretheoutputaffectstheDGP HowdoIdownloadmacOSMontereyonunsupportedMac? ConvertanintegertoIEEE754float Howdoparty-listsystemsaccommodateindependentcandidates? Whatisthebestwaytocalculatetruepasswordentropyforhumancreatedpasswords? CanIuseaspritesheetfromanexistingvideogameformypromotionalreel? MakeaCourtTranscriber Isitcorrecttochangetheverbto"being"in"Despitenoonewashurtinthisincident…"? Whyarefighterjetssoloudwhendoingslowflight? WherewasthisneonsignofadragondisplayedinLosAngelesinthe1990s?Isitstilltherenow? Whataretheargumentsforrevengeandretribution? Howdouncomputablenumbersrelatetouncomputablefunctions? Alternativeversionsofbreathing? WhydidGodprohibitwearingofgarmentsofdifferentmaterialsinLeviticus19:19? HowtofindthebordercrossingtimeofatraininEurope?(Czechbureaucracyedition) Interpretinganegativeself-evaluationofahighperformer ElectronicCircuitsforSafeInitiationofPyrotechnics? My(large)employerhasn'tregisteredanobviousmisspellingoftheirprimarydomainURL WillIgetdeniedentryafterIremovedavisasticker?Ismypassportdamaged? Howdocucumbershappen?Whatdoes"verypoorlypollinatedcucumber"meanexactly?Howcanpollinationbe"uneven"? HowtogetridofUbuntuProadvertisementwhenupdatingapt? Wouldextractinghydrogenfromthesunlessenitslifespan? Canyoufindit? WhyamIgettingasortwhenIhaveanindex? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?