Search code examples
svnmime-typessmartsvn

How to force SVN to detect UTF-16 XML files as plaintext files by default?


We have many xml files and most of them are UTF-16 encoded.

When I add a file to subversion using SmartSVN it always gets the svn:mime-type=application/octet-stream.

This prevents the visual DIFF tool from SmartSVN to work on these files which is very annoying.

From the SVN FAQ: http://subversion.apache.org/faq.html#binary-files

When you first add or import a file into Subversion, the file is examined to determine if it is a binary file. Currently, Subversion just looks at the first 1024 bytes of the file; if any of the bytes are zero, or if more than 15% are not ASCII printing characters, then Subversion calls the file binary. This heuristic might be improved in the future, however.

This is very stupid when UTF-16 files are used, because they contain ~50% zero in most cases.

I also read that there is a ways to set properties automatically from the SVN client: http://www.mediawiki.org/wiki/Subversion/auto-props

Does this also allow to remove the auto detected binary mime type?

Is it possible to set this on the repository / svn server somehow, so I don't have to set it on every workstation?


Solution

    1. You can't redefine mime-type for UTF-16 XMLs only (but can - for all xmls)
    2. I don't know good way of redefining mim-type on server or on per-repository basis

    If the above points do not frighten you, you can globally (per client's host) redefine mime-type on client's subversion config files: %AppData%\Subversion\config, [auto-props] section. Something like

    *.xml = svn:mime-type=text/xml