Profilo di Alasdairalasdair's brain dumpBlogElenchiAmici Strumenti Guida

Blog


01/06/2009

VS2008, Item Templates and Unicode files to ANSI

I’ve just created a load of text files with Visual Studio 2008, only to discover they’re:

Unicode (UTF-8 with signature) – Codepage 65001

Very annoying because I wanted ANSI files, and they get marked as binary in Subversion (well, actually they get automatically tagged with the svn:mime-type “application/octet-stream”).

The cause of this is that the item templates for TextFile in Visual Studio have the Unicode byte marks.

The solution is to knobble them in your copy of visual studio:

Go to

%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates

and search for TextFile.zip.

On x64 they’re here:

%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates

Anyway, depending on your edition of Visual Studio and your installation choices, you may find several of these. In each case, you need to overwrite the two-byte or three-byte TextFile.txt in the zip file with a zero-byte version.

You’ll also want to similarly knobble any other TextFile.txt you can find in your Visual Studio directory – there are several in mine which are used to create files when not inside a particular project type.

Once you’ve sorted all this out, you need Visual Studio to refresh template cache:

 

x86: "%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /setup

x64: "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" /setup

 

So, what do you do if you have just created dozens of Unicode files which you now rather wish were ANSI?

Well, my answer in powershell 1.0 is as follows:

Get-ChildItem -recurse -filter "*.sol" | foreach { $_.Name | Out-Default; ( Get-Content $_.PSPath ) | Set-Content $_.PSPath }

Obviously my files all ended in the .sol extension and were spread around a whole directory tree – you can change the options for Get-ChildItem to suit your purposes.

And finally, because for some reason (I think TortoiseSVN had already added the svn:mime-type “application/octet-stream” properties):

svn propdel --recursive --quiet svn:mime-type .\*

And that’s all for now, folks!

Commenti

Attendere...
Il commento immesso è troppo lungo. Immetti un commento più breve.
Immissione non effettuata. Riprova.
Impossibile aggiungere il commento al momento. Riprova più tardi.
Per aggiungere un commento è necessaria l'autorizzazione di un genitore. Chiedi autorizzazione
I tuoi genitori hanno disattivato i commenti.
Impossibile eliminare il commento al momento. Riprova più tardi.
Hai raggiunto il numero massimo di commenti pubblicabili giornalmente. Riprova tra 24 ore.
Impossibile lasciare commenti. La funzionalità è stata disattivata perché i sistemi hanno rilevato una possibile attività di spamming dal tuo account. Se ritieni che il tuo account è stato disattivato per errore, contatta il supporto tecnico di Windows Live.
Esegui il seguente controllo di protezione per completare la pubblicazione del commento.
I caratteri digitati nel controllo di protezione devono corrispondere ai caratteri dell'immagine o della riproduzione audio.

Per aggiungere un commento, accedi con il tuo Windows Live ID (se utilizzi Hotmail, Messenger o Xbox LIVE possiedi già un Windows Live ID). Accedi


Non hai ancora un Windows Live ID? Registrati

Riferimenti

L'URL di riferimento per questo intervento è:
http://alasdaircs.spaces.live.com/blog/cns!DEC5E544601A7A3D!202.trak
Blog che fanno riferimento a questo intervento
  • Nessuno