tjscience / RoboSharp

RoboSharp is a .NET wrapper for the awesome Robocopy windows application.
MIT License
216 stars 67 forks source link

Robosharp can't work with non-english chars #83

Closed Dan-Baruch closed 2 years ago

Dan-Baruch commented 4 years ago

When trying to set source / destination of copy that contains a directory with Hebrew characters the callback events does not return proper file name and that can't be worked with.

giesalabs commented 3 years ago

it don't copy the files right?

could be a charset problem in the arguments?? there are many example on google: https://stackoverflow.com/questions/2627891/does-process-startinfo-arguments-support-a-utf-8-string

in this link they suggest to use Arguments = Encoding.Default.GetString(Encoding.UTF8.GetBytes(args));

so in RoboCommand.cs at line 288 maybe is possible to try this line process.StartInfo.Arguments = Encoding.Default.GetString(Encoding.UTF8.GetBytes(GenerateParameters()));

but i never try a different charset in the Arguments and i'm not a Robosharp developer, so the developers team should try out anyway just for curiosity, could you try the code line?

Dan-Baruch commented 3 years ago

I've tried this line long long ago to no avail. I ended up not using this library though, as I couldn't find a way around that

Dan-Baruch commented 3 years ago

Well, I ended up not using roboCopy. I used to be able to make it work only if I were to write all the paths to a log file, but that also had it's limitations.

giesalabs commented 3 years ago

after more test it works with non english chars, in the test i did the mistake to use chars not allowed in a windows path

Dan-Baruch commented 3 years ago

Well, I know that if my target ends with a single directory in Hebrew characters it was ok. If, how ever, I had something like: C:\EnglishPath\EnglishPath\HebrewPath\EnglishPath\HebrewFile It failed. Of course, there's no relevant to how many directories there are, it's only a matter that there's a file in Hebrew inside a directory in Hebrew.

JoE-Seeve commented 3 years ago

I used the following line to initialize the CodePage to match the operating system. That worked for me (e.g. with German special characters). This should make it possible to get all characters of the currently installed language back from RoboSharp.

            process.StartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage);

In the current version, no matter what I set, no German special characters are returned. If you can, you should also try other languages ​​with the above-mentioned supplement.