Bing
Bing

Reputation: 3171

SVN update failing: E000022: Can't convert string from 'UTF-8' to native encoding

I'm attempting to run an SVN update from a PHP page, when it is visited by someone. The relevant PHP code I'm specifically running is:

echo exec("2>&1 svn update --username bing --password s3cr3t example/", $output);
echo print_r($output, true)."<br/>";

I get the following message printed in my browser when this code is run:

svn: E000022: /var/www/html/example/apple-touch-icon-114?\195?\151114-precomposed.pngArray ( [0] => Updating 'example': 1 => svn: E000022: Can't convert string from 'UTF-8' to native encoding: [2] => svn: E000022: /var/www/html/example/apple-touch-icon-114?\195?\151114-precomposed.png ) Array ( [0] => Updating 'example': 1 => svn: E000022: Can't convert string from 'UTF-8' to native encoding: [2] => svn: E000022: /var/www/html/example/apple-touch-icon-114?\195?\151114-precomposed.png )

There was a file named apple-touch-icon-114×114-precomposed.png (notice the × symbol is for multiplication, not the letter x) in the /var/www/html/example/ folder, but I renamed it to use the letter x instead, and updated the repository (which is actually housed on a separate machine entirely) as well.

Still though, when I attempt to run this I get the same error. I searched for this bug and found a few other questions which suggested running export LC_CTYPE=en_US.UTF-8 or export LC_ALL=en_US.UTF-8, but they never explain what that is or where these commands should be run. I tried running them both via command line, then wrote the following lines just before the exec/print_r listed above, so the whole thing looks like this:

echo exec("2>&1 export LC_ALL=en_US.UTF-8", $output);
echo print_r($output, true)."<br/>";
echo exec("2>&1 svn update --username bing --password s3cr3t example/", $output);
echo print_r($output, true)."<br/>";

No matter what, I'm still getting the same error message and no update of the example directory.

Does anyone know what I'm doing wrong? I'm sure it's something simple, but I've been stuck on this for a day now.

Upvotes: 0

Views: 3250

Answers (1)

Peter Parker
Peter Parker

Reputation: 29715

exec opens a new shell every time it is invoked. You need to create a batch file which executes both commands in a single exec call.

If you are working on windows, you may still out of luck as the encoding is not always able to convert everything as the standard cmd font cannot display all utf-8 codes (you may need to change the default font to a utf-8 capable font like Courier new)

Upvotes: 1

Related Questions