Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

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

Results 1 to 4 of 4
Share This Thread →
  1. #1
    fletchsod is offline Contributing User
    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
    subbaram_k's Avatar
    subbaram_k is offline M o D e R a T o R
    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

  3. #3
    fletchsod is offline Contributing User
    Join Date
    Jul 2004
    Location
    Jacksonville, Florida
    Posts
    381
    Rep Power
    15
    Quote 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?

  4. #4
    subbaram_k's Avatar
    subbaram_k is offline M o D e R a T o R
    Join Date
    Feb 2004
    Location
    Missouri
    Posts
    470
    Rep Power
    43
    in c#

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

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

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

ASP Free Advertisers and Affiliates