Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990430
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:29:36+00:00 2026-05-20T06:29:36+00:00

According to Spolsky I can’t call myself a developer, so there is a lot

  • 0

According to Spolsky I can’t call myself a developer, so there is a lot of shame behind this question…

Scenario: From a C# application, I would like to take a string value from a SQL db and use it as the name of a directory. I have a secure (SSL) FTP server on which I want to set the current directory using the string value from the DB.
Problem: Everything is working fine until I hit a string value with a “special” character – I seem unable to encode the directory name correctly to satisfy the FTP server.

The code example below

  • uses “special” character é as an example
  • uses WinSCP as an external application for the ftps comms
  • does not show all the code required to setup the Process “_winscp”.
  • sends commands to the WinSCP exe by writing to the process standardinput
  • for simplicity, does not get the info from the DB, but instead simply declares a string (but I did do a .Equals to confirm that the value from the DB is the same as the declared string)
  • makes three attempts to set the current directory on the FTP server using different string encodings – all of which fail
  • makes an attempt to set the directory using a string that was created from a hand-crafted byte array – which works

Process _winscp = new Process();
byte[] buffer;

string nameFromString = "Sinéad O'Connor";
_winscp.StandardInput.WriteLine("cd \"" + nameFromString + "\"");

buffer = Encoding.UTF8.GetBytes(nameFromString);
_winscp.StandardInput.WriteLine("cd \"" + Encoding.UTF8.GetString(buffer) + "\"");

buffer = Encoding.ASCII.GetBytes(nameFromString);
_winscp.StandardInput.WriteLine("cd \"" + Encoding.ASCII.GetString(buffer) + "\"");

byte[] nameFromBytes = new byte[] { 83, 105, 110, 130, 97, 100, 32, 79, 39, 67, 111, 110, 110, 111, 114 };
_winscp.StandardInput.WriteLine("cd \"" + Encoding.Default.GetString(nameFromBytes) + "\"");

The UTF8 encoding changes é to 101 (decimal) but the FTP server doesn’t like it.

The ASCII encoding changes é to 63 (decimal) but the FTP server doesn’t like it.

When I represent é as value 130 (decimal) the FTP server is happy, except I can’t find a method that will do this for me (I had to manually contruct the string from explicit bytes).

Anyone know what I should do to my string to encode the é as 130 and make the FTP server happy and finally elevate me to level 1 developer by explaining the only single thing a developer should understand?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:29:37+00:00Added an answer on May 20, 2026 at 6:29 am

    130 isn’t ASCII (ASCII is only 7bits — see the Encoding.ASCII documentation — so it whacks the “é” into a normal “?” because it has nothing better to do). UTF-8 is actually encoding the character into two bytes (decimal: 195 & 169) but preserves the code-point.

    Use a code-page explicitly, such as Latin (CP 1252) — needs to match whatever other side is. As from below, there is no “130” in the output so… not the encoding you need 🙂 But the same applies: use an encoding for a specific code-page.

    Edit: As Hans Passant explained in a comment, the code-page to use here is MS-DOS (CP 437) which will result in the desired results.

    // LINQPad -- Encoding is System.Text.Encoding
    var enc = Encoding.GetEncoding(1252);
    string.Join(" ", enc.GetBytes("Sinéad O'Connor")).Dump();
    // -> 83 105 110 233 97 100 32 79 39 67 111 110 110 111 114
    

    See: http://msdn.microsoft.com/en-us/goglobal/bb688114 for more.

    Happy coding.

    Btw. good selection in artists — if it was intentional :p

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this answer, it seems to be ok to call model from the
According to this post , I am using a data context per call, so
According to the answers to this question, I cannot embed a file version in
According to this question Raphael - event when mouse near element i create a
According to this , ActiveRecord first generates the SQL: SELECT * FROM clients LIMIT
According to http://lipas.uwasa.fi/~ts/info/proctips.html#orrules , you can make basic or rules in .procmailrc with something
According to the class ElementType in the API, you can annotate local variables and
According to Steffen's post this is an efficient way to generate random BOOL s
According to JavaScript Patterns book (p. 79), this should work: var ob = {
according to my knowledge, this feature already exists in PHP. lets look at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.