3

I am trying to upload a file whose name is written in Arabic language to ftp server, and i succeed in uploading the file but i have a problem at the ftp server, where the uploaded file name is incorrect and take unreadable format like "????????" or "*************" or any format other than Arabic.

I have tried to encode file name to UTF-8 or "Default" ANSI encoding but failed what can i do to solve this problem ? Here is the following code which used to encode file path in VB .Net:

FIleNamePath = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(FIleNamePath))

Thanks in advance

Ahmy
  • 5,420
  • 8
  • 39
  • 50
  • Can any one help me pleaseeeeeeeeeeeeeeeeeeeee? – Ahmy May 30 '12 at 14:33
  • Do you know if the server you are uploading to supports UTF8 filenames? Also could you tell us how you are doing the FTP connection in VB.NET? The FtpWebRequest class? – Jeff B May 31 '12 at 15:03
  • I don't know if the FTP server support UTF8 file-names or not.And with respect to the code i am using the following line for uploading: My.Computer.Network.UploadFile(F, filePath, U, P, False, 600000) – Ahmy Jun 03 '12 at 08:05
  • Huh, it seems like that should be able to do it since it takes the filename as a string which is UTF-16 encoding in .NET. The remarks section in the documentation mentions that UploadFile outputs trace information, you might see if you can find any useful information in the output. http://msdn.microsoft.com/en-us/library/dfkdh7eb(v=vs.80).aspx – Jeff B Jun 05 '12 at 02:57
  • The ftp server is supporting arabic and i checked that by accessing the ftp server through opening a window and write the ftp path then type user name and password and then accessed the ftp server through windows explorer and found files names in correct arabic format but the problem when i try to download these files or try browsing it through any ftp client application like "Core ftp">>>> how can i solve this issue? – Ahmy Jun 19 '12 at 08:30
  • Hmm, you've listed about everything I can think of. I know most FTP client have a binary vs ascii format. That's the only thing I can think of. You could expand the question and put a bounty on it, perhaps. – Jeff B Jun 19 '12 at 12:57
  • So, now answers are ready with bounty offered? I need to know what is the reason for that and then i can search in this direction – Ahmy Jun 19 '12 at 14:44
  • 3
    Sorry, I don't understand your question. I was suggesting that a bounty might bring this question to the attention of people who know more than me. I hope you can find a good answer! :) – Jeff B Jun 20 '12 at 13:10
  • 1
    Did you make sure that VB is reading the file properly? What I would do is add a break point in your VB code after reading the filename and make sure that the file name is read correctly by VB (examine the value stored in FileNamePath) before troubleshooting the FTP server Operating System options – Ahmad Jul 21 '12 at 08:16

1 Answers1

0

If I understand you right the problem is, that the conversion of any string with your code should generate you the original string.

dim input = "abcü"
dim output = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(input))
assert.areEqual(input, output)

For me this code works (with German umlauts).

So maybe your input is not a UTF-8 string? Try to check what Encoding.UTF8.GetBytes produces (how many characters, try to manual convert is, ...)

habakuk
  • 2,712
  • 2
  • 28
  • 47