0

I'm using adb push to copy files from Windows to my Nexus 7 from command line (from a C# desktop application). The problem is that files with accents won't be copy properly because of encoding differences...

Is there any way to set encoding type of adb before copy? Or do you know another way to push files from my desktop to my Device in command line?

Thanks a lot,

Mr.Me
  • 9,192
  • 5
  • 39
  • 51
castrogne
  • 521
  • 1
  • 4
  • 17
  • I renamed my files using UTF8 ("?" appears un windows, normal...) But when i use then adb push, it says "file not found" because of the ? char in name... – castrogne Mar 20 '13 at 09:15

2 Answers2

1

In short Android uses FAT file system. and FAT uses UTF-8 in file names. Which means that even if you managed to pass a file name which is not UTF-8 as command line argument to adb somehow, adb behaviour is not determind because of the above restrection. A good work around is:

  • to read the file name and change it to UTF-8 Complaint name.

    byte[] bytes = Encoding.Default.GetBytes(originalPath);
    newPath= Encoding.UTF8.GetString(bytes);
    
  • copy the file to the newly generated name. "if the new name doesn't match the original"

  • use adb to upload the file and then delete the copy.
Community
  • 1
  • 1
Mr.Me
  • 9,192
  • 5
  • 39
  • 51
0

adb does not recode the file it just pushes the binary content as is. You must create your file in the correct encoding (UTF-8) before using adb push.

Edit: Ah, the problem is not with files containing accented characters but with file names with such characters. Can't you simply push the file with a simple name and then rename it on the device?

Henry
  • 42,982
  • 7
  • 68
  • 84