SVN Error: Can't convert string from native encoding to 'UTF-8'

前端 未结 11 946
花落未央
花落未央 2020-12-13 06:29

I\'ve got a post-commit hook script that performs a SVN update of a working copy when commits are made to the repository.

When users commit to the repository from th

相关标签:
11条回答
  • 2020-12-13 06:52
    1. It does not change the encoding of the file. It changes the encoding of the filename (to something that every client can hopefully understand).
    2. Allowed by whom ? NTFS uses 16-bit code points, and Windows can expose the file names in various encodings, based on how you ask for it (it will try to convert them to the encoding you ask for). Now... That bit (how you ask) depends on the specific svn client you use. It sounds to me like a bug in TortoiseSVN.

    Edit to add:

    Ugh. I misunderstood the symptoms. the svn server stores everything in utf-8 (and it seems that it did that successfully).

    The post-commit hook is the bit that fails to convert from UTF-8. If I understand what you're saying correctly, the post-commit hook on the server triggers an svn update to a shared drive (the svn server therefore starts an svn client to itself...) ? This means that the configuration that needs to be fixed is the one for the client on the server. Check the LANG / LC_ALL on the environment executing the svn server.. As it happens, the hooks are run in a vacuum environment (see Tip). So you should set the variable in the hook itself.

    See also this page for info on how svn handles localisation

    0 讨论(0)
  • 2020-12-13 06:52

    It seems that all LC_ varables need .UTF8 at the end. For example, I happened to have LC_ALL, LC_TIME, and LC_CTYPE defined. After setting LC_CTYPE the problem was not solved, so I needed to type LC_ALL as well and then it worked:

    LC_ALL=en_US.UTF-8
    LC_TIME=en_DK.UTF-8
    LC_CTYPE=en_US.UTF-8
    

    In order to avoid the problem again, I copied the file to a different name, removed the old one from svn, added new one to svn, and send a message to a collaborator not to do this.

    0 讨论(0)
  • 2020-12-13 06:53

    Don't forget to generate those locales in your system
    (as root)

    example for Ru

    locale-gen ru_RU.CP1251
    locale-gen ru_RU.UTF-8
    dpkg-reconfigure locales
    
    0 讨论(0)
  • 2020-12-13 06:54

    For information, I got this error on commit native encoding to 'UTF-8'with a windows client tortoise svn,

    when my URL of repository was :

    http://x.x.x.x/svn/myrepos

    I changed my URL of repository for :

    svn://x.x.x.x/myrepos

    and now all is perferct.

    I think this information will be useful to some.

    0 讨论(0)
  • 2020-12-13 06:58

    Yet another example:

    $ svn update
    svn: Error converting entry in directory '.' to UTF-8
    svn: Can't convert string from native encoding to 'UTF-8':
    
    $ export LC_CTYPE=en_US.UTF-8
    
    $ svn update
    

    (... and all is fine now)

    0 讨论(0)
提交回复
热议问题