Solved

FTP client and national characters

Posted on 2004-10-28
623 Views
Last Modified: 2012-06-21
Hi!

I'm writing an FTP client in VB.NET for educational purpose, so using an third party FTP client is not an option.
I'm having problem with sending the CWD command (Change Working Directory) to the FTP Server running IIS 6.
It works as expected with non-national characters, but when i try to change to a directory with national characters in the name, it doesn't work!
The server replies with code 550, file not found.

I've tried sending the command and directory name encoded in both UTF-7 and UTF-8, without success.
How do i make this work with national characters?

Any help appreciated!

Regards
Kristoffer
0
Question by:CyberStoffe
    11 Comments
     
    LVL 4

    Expert Comment

    by:andrewharris
    DOes the IIS Server have the applicable character set installed?

    Andrew
    0
     
    LVL 96

    Expert Comment

    by:Bob Learned
    Do other ways (like in a NT command prompt FTP session) accept the national characters?

    Bob
    0
     

    Author Comment

    by:CyberStoffe
    andrewharris:
    Don't know if the IIS Server has the applicable character set installed. Where do I check it?

    TheLearnedOne:
    It doesn't work in a NT command prompt FTP session, but other FTP clients are able to change to the directory with national characters.

    /Kristoffer
    0
     
    LVL 96

    Expert Comment

    by:Bob Learned
    Do you have anything that can shed a little more light on the situation?  Sample code, FTP site address, etc.?

    Bob
    0
     

    Author Comment

    by:CyberStoffe
    The part of the code where I send the command to the FTP Server looks like this:

        Dim command As String = "CWD Images" & vbNewLine
        Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(command)
        Dim stream As NetworkStream = TcpClient.GetStream()

        stream.Write(buffer, 0, buffer.Length)

    The FTP Server is on my local network and is running IIS 6 on Windows Server 2003.
    The language version of Windows Server is swedish, and i'm having problem with changing to a directory with a swedish character in the directory name. It works with IE and other FTP Clients, bot not with the code above and not with the FTP command prompt utility.

    In the response from the server (550 File not found), the national character is replaced with a question mark.

    /Kristoffer
    0
     
    LVL 4

    Expert Comment

    by:andrewharris
    Just out of curiosity, what do you get from PWD on the dir that contains the dir with the swedish chars?

    Andrew
    0
     

    Author Comment

    by:CyberStoffe
    I managed to get the right characters back in the server response by using UTF7 encoding when I convert the byte array to a string.
    No question marks anymore.

    But it still says "550 File not found" when i send a CWD command encoded in UTF7.
    Enclosing the directory name in double quotes doesn't make any difference.

    If I send a LIST command, the directory list returned looks OK.
    The national characters are displayed correctly.

    /Kristoffer
    0
     
    LVL 14

    Accepted Solution

    by:
    Turning the server into UTF8 mode (RFC-2640 compliant) would be using the
    OPTS UTF8 ON
    command. The server should return 220 UTF8 OPTS ON (or so) if supported (can be queried using FEAT). Afterwards, all textual data (dir/file names, dir listings, etc.) will be UTF8.

    If that does not work, I'd suggest to use Encoding.Default - which is usually the ISO-8859-1 in Europe. I know that there is a risk that this does not match the server encoding, but the chances are good that it will work with FTP servers using English charsets as well as with geographically close FTP servers using the same (or a similar) encoding.
    0
     

    Author Comment

    by:CyberStoffe
    Thanks for your help, AvonWyss!

    Encoding.Default did the trick!
    I also tried to send OPTS UTF8 ON to the server, but it responded "501 option not supported".

    /Kristoffer
    0
     
    LVL 14

    Expert Comment

    by:AvonWyss
    Perfect. Hopefully, more servers will support the UTF8 option in the future, because this gets rid of endcoding issues for good...
    0
     

    Author Comment

    by:CyberStoffe
    ...and of course thanks to anyone else who have tried to help me!
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now