#1
  1. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jul 2004
    Location
    Jacksonville, Florida
    Posts
    381
    Rep Power
    15

    C# - How to convert ASCII 13 to "\n" in char and string?


    I'm lost right now... There is a function in other language that allow me to convert the ascii's "13" to char or string which is "\n". I can't seem to get this to work in C#... I'm trying to split the string into arrays... Thanks...

    Code:
       private string ParseViewSource(string strWebData) {
          string strWebDataArray = strWebData.Split(System.Char.ToString(13));
    
          for (int x = 0;x < strWebDataArray.Length;x++) {
              /* ====================== */
              /* Debug Purpose Only */
               //Response.Write(x & " == " & strWebDataArray(x))
             /* ====================== */
    
             //Decide the background color of each line based on the remainder of $i/2...
             if (x % 2 != 0) {
                strBgColor = "padding:3px;font:9pt verdana;background-color:#DDF5CA;" + strHorizontalRulerBottom;
             } else {
                 strBgColor = "padding:3px;font:9pt verdana;background-color:#DDF5CA;" + strHorizontalRulerBottom;
             }
    
             //Remove stray line returns...
             strWebDataArray[x] = System.Text.RegularExpressions.Regex.Replace(System.Char.ToString(strWebDataArray[x]), System.Char.ToString(13), "");
         }
    }
  2. #2
  3. M o D e R a T o R
    ASP Discoverer (100 - 499 posts)

    Join Date
    Feb 2004
    Location
    Missouri
    Posts
    470
    Rep Power
    43
    mystring.Replace("\r","<br>");

    or

    string myOutputString = Regex.Replace(myInputString, @"\r", "<br>",
    RegexOptions.Multiline);
    Knowledge is power. Ignorance is no excuse.

    Useful Post? Click on Scales
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jul 2004
    Location
    Jacksonville, Florida
    Posts
    381
    Rep Power
    15
    Originally Posted by subbaram_k
    mystring.Replace("\r","<br>");

    or

    string myOutputString = Regex.Replace(myInputString, @"\r", "<br>",
    RegexOptions.Multiline);
    So, I can't use the number 13 of the ASCII character?
  6. #4
  7. M o D e R a T o R
    ASP Discoverer (100 - 499 posts)

    Join Date
    Feb 2004
    Location
    Missouri
    Posts
    470
    Rep Power
    43
    in c#

    "\r" = chr(13)
    "\n" = chr(10)

Similar Threads

  1. Eliminating non number / char from string
    By Darkness in forum .NET Development
    Replies: 11
    Last Post: September 6th, 2005, 10:26 AM
  2. Stored Procedure only inserting first char per string
    By itsdanny in forum .NET Development
    Replies: 2
    Last Post: January 10th, 2005, 08:01 AM
  3. find position of a char in a string
    By GazouTG in forum ASP Development
    Replies: 3
    Last Post: October 27th, 2004, 02:30 PM
  4. File I/O and String Manupulation
    By alee7 in forum Visual Basic Programming
    Replies: 1
    Last Post: June 19th, 2004, 12:23 PM
  5. Replies: 1
    Last Post: April 19th, 2004, 04:33 PM

IMN logo majestic logo threadwatch logo seochat tools logo