C# equiv of Chr(13)

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFuIE5hc2g=?=, Nov 1, 2004.

  1. Lo,

    In a previous version of an app, I used replace to convert multiline text
    boxes to something easier to put in a database, and then i used
    replace(chr(13), "<br>") when i needed to show the data.

    I'm now working on a new version of this app, and im using C# / .NET.
    Obviously I'm using the old database, but I cant find out how to do
    replace(chr(13), "<br>").

    Basically, what's Chr(13) in C# :eek:)

    Cheers


    Dan
     
    =?Utf-8?B?RGFuIE5hc2g=?=, Nov 1, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?RGFuIE5hc2g=?=

    Karl Seguin Guest

    Try System.Environment.NewLine

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Dan Nash" <> wrote in message
    news:...
    > Lo,
    >
    > In a previous version of an app, I used replace to convert multiline text
    > boxes to something easier to put in a database, and then i used
    > replace(chr(13), "<br>") when i needed to show the data.
    >
    > I'm now working on a new version of this app, and im using C# / .NET.
    > Obviously I'm using the old database, but I cant find out how to do
    > replace(chr(13), "<br>").
    >
    > Basically, what's Chr(13) in C# :eek:)
    >
    > Cheers
    >
    >
    > Dan
     
    Karl Seguin, Nov 1, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?RGFuIE5hc2g=?=

    Chris Austin Guest

    Dan,

    I think you are looking for "\n".

    -Chris
    http://weblogs.austinspad.com/caustin

    "Dan Nash" <> wrote in message
    news:...
    > Lo,
    >
    > In a previous version of an app, I used replace to convert multiline text
    > boxes to something easier to put in a database, and then i used
    > replace(chr(13), "<br>") when i needed to show the data.
    >
    > I'm now working on a new version of this app, and im using C# / .NET.
    > Obviously I'm using the old database, but I cant find out how to do
    > replace(chr(13), "<br>").
    >
    > Basically, what's Chr(13) in C# :eek:)
    >
    > Cheers
    >
    >
    > Dan
     
    Chris Austin, Nov 1, 2004
    #3
  4. Hi guys

    Neither of those work. I think I need to actually put the ascii char 13, but
    im not sure how to do it. In the db it looks like a little square box! It's
    that I want to replace with <br>.

    Any ideas?


    "Chris Austin" wrote:

    > Dan,
    >
    > I think you are looking for "\n".
    >
    > -Chris
    > http://weblogs.austinspad.com/caustin
    >
    > "Dan Nash" <> wrote in message
    > news:...
    > > Lo,
    > >
    > > In a previous version of an app, I used replace to convert multiline text
    > > boxes to something easier to put in a database, and then i used
    > > replace(chr(13), "<br>") when i needed to show the data.
    > >
    > > I'm now working on a new version of this app, and im using C# / .NET.
    > > Obviously I'm using the old database, but I cant find out how to do
    > > replace(chr(13), "<br>").
    > >
    > > Basically, what's Chr(13) in C# :eek:)
    > >
    > > Cheers
    > >
    > >
    > > Dan

    >
    >
    >
     
    =?Utf-8?B?RGFuIE5hc2g=?=, Nov 1, 2004
    #4
  5. =?Utf-8?B?RGFuIE5hc2g=?=

    Chris Austin Guest

    Have you tried using RegularExpressions yet? Perhaps doing something like
    the following will help:
    String myNewTest = Regex.Replace(test, @"\n", "<br>",
    RegexOptions.Multiline);

    You will have to import the System.Text.RegularExpressions library.

    Here is a list of the different characters escapes
    http://msdn.microsoft.com/library/d...en-us/cpgenref/html/cpconcharacterescapes.asp

    HTH

    -Chris
    ~
    http://weblogs.austinspad.com/caustin

    "Dan Nash" <> wrote in message
    news:...
    > Hi guys
    >
    > Neither of those work. I think I need to actually put the ascii char 13,

    but
    > im not sure how to do it. In the db it looks like a little square box!

    It's
    > that I want to replace with <br>.
    >
    > Any ideas?
    >
    >
    > "Chris Austin" wrote:
    >
    > > Dan,
    > >
    > > I think you are looking for "\n".
    > >
    > > -Chris
    > > http://weblogs.austinspad.com/caustin
    > >
    > > "Dan Nash" <> wrote in message
    > > news:...
    > > > Lo,
    > > >
    > > > In a previous version of an app, I used replace to convert multiline

    text
    > > > boxes to something easier to put in a database, and then i used
    > > > replace(chr(13), "<br>") when i needed to show the data.
    > > >
    > > > I'm now working on a new version of this app, and im using C# / .NET.
    > > > Obviously I'm using the old database, but I cant find out how to do
    > > > replace(chr(13), "<br>").
    > > >
    > > > Basically, what's Chr(13) in C# :eek:)
    > > >
    > > > Cheers
    > > >
    > > >
    > > > Dan

    > >
    > >
    > >
     
    Chris Austin, Nov 1, 2004
    #5
  6. Hi Chris,

    Just tried that, same result: it does nothing. I'm lost!

    Dan


    "Chris Austin" wrote:

    > Have you tried using RegularExpressions yet? Perhaps doing something like
    > the following will help:
    > String myNewTest = Regex.Replace(test, @"\n", "<br>",
    > RegexOptions.Multiline);
    >
    > You will have to import the System.Text.RegularExpressions library.
    >
    > Here is a list of the different characters escapes
    > http://msdn.microsoft.com/library/d...en-us/cpgenref/html/cpconcharacterescapes.asp
    >
    > HTH
    >
    > -Chris
    > ~
    > http://weblogs.austinspad.com/caustin
    >
    > "Dan Nash" <> wrote in message
    > news:...
    > > Hi guys
    > >
    > > Neither of those work. I think I need to actually put the ascii char 13,

    > but
    > > im not sure how to do it. In the db it looks like a little square box!

    > It's
    > > that I want to replace with <br>.
    > >
    > > Any ideas?
    > >
    > >
    > > "Chris Austin" wrote:
    > >
    > > > Dan,
    > > >
    > > > I think you are looking for "\n".
    > > >
    > > > -Chris
    > > > http://weblogs.austinspad.com/caustin
    > > >
    > > > "Dan Nash" <> wrote in message
    > > > news:...
    > > > > Lo,
    > > > >
    > > > > In a previous version of an app, I used replace to convert multiline

    > text
    > > > > boxes to something easier to put in a database, and then i used
    > > > > replace(chr(13), "<br>") when i needed to show the data.
    > > > >
    > > > > I'm now working on a new version of this app, and im using C# / .NET.
    > > > > Obviously I'm using the old database, but I cant find out how to do
    > > > > replace(chr(13), "<br>").
    > > > >
    > > > > Basically, what's Chr(13) in C# :eek:)
    > > > >
    > > > > Cheers
    > > > >
    > > > >
    > > > > Dan
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?RGFuIE5hc2g=?=, Nov 1, 2004
    #6
  7. =?Utf-8?B?RGFuIE5hc2g=?=

    bruce barker Guest

    in c#

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


    mystring.Replace("\r","<br>");

    -- bruce (sqlwork.com)


    "Dan Nash" <> wrote in message
    news:...
    > Lo,
    >
    > In a previous version of an app, I used replace to convert multiline text
    > boxes to something easier to put in a database, and then i used
    > replace(chr(13), "<br>") when i needed to show the data.
    >
    > I'm now working on a new version of this app, and im using C# / .NET.
    > Obviously I'm using the old database, but I cant find out how to do
    > replace(chr(13), "<br>").
    >
    > Basically, what's Chr(13) in C# :eek:)
    >
    > Cheers
    >
    >
    > Dan
     
    bruce barker, Nov 1, 2004
    #7
  8. =?Utf-8?B?RGFuIE5hc2g=?=

    Chris Austin Guest

    This worked for me. Difference is it needed to use "\r" instead of "\n".

    static void Main(string[] args)
    {
    FileStream fs = File.OpenRead("Data.txt");
    StreamReader reader = new StreamReader(fs);
    string myInput = reader.ReadToEnd();
    reader.Close();
    fs.Close();
    string myOutput = Regex.Replace(myInput, @"\r", "<br>",
    RegexOptions.Multiline);

    Console.WriteLine(myOutput);
    }

    Data.Text contained:

    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.
    This is a test for new lines.

    HTH

    -Chris
    ~
    http://weblogs.austinspad.com/caustin

    "Dan Nash" <> wrote in message
    news:...
    > Hi Chris,
    >
    > Just tried that, same result: it does nothing. I'm lost!
    >
    > Dan
    >
    >
    > "Chris Austin" wrote:
    >
    > > Have you tried using RegularExpressions yet? Perhaps doing something

    like
    > > the following will help:
    > > String myNewTest = Regex.Replace(test, @"\n", "<br>",
    > > RegexOptions.Multiline);
    > >
    > > You will have to import the System.Text.RegularExpressions library.
    > >
    > > Here is a list of the different characters escapes
    > >

    http://msdn.microsoft.com/library/d...en-us/cpgenref/html/cpconcharacterescapes.asp
    > >
    > > HTH
    > >
    > > -Chris
    > > ~
    > > http://weblogs.austinspad.com/caustin
    > >
    > > "Dan Nash" <> wrote in message
    > > news:...
    > > > Hi guys
    > > >
    > > > Neither of those work. I think I need to actually put the ascii char

    13,
    > > but
    > > > im not sure how to do it. In the db it looks like a little square box!

    > > It's
    > > > that I want to replace with <br>.
    > > >
    > > > Any ideas?
    > > >
    > > >
    > > > "Chris Austin" wrote:
    > > >
    > > > > Dan,
    > > > >
    > > > > I think you are looking for "\n".
    > > > >
    > > > > -Chris
    > > > > http://weblogs.austinspad.com/caustin
    > > > >
    > > > > "Dan Nash" <> wrote in message
    > > > > news:...
    > > > > > Lo,
    > > > > >
    > > > > > In a previous version of an app, I used replace to convert

    multiline
    > > text
    > > > > > boxes to something easier to put in a database, and then i used
    > > > > > replace(chr(13), "<br>") when i needed to show the data.
    > > > > >
    > > > > > I'm now working on a new version of this app, and im using C# /

    ..NET.
    > > > > > Obviously I'm using the old database, but I cant find out how to

    do
    > > > > > replace(chr(13), "<br>").
    > > > > >
    > > > > > Basically, what's Chr(13) in C# :eek:)
    > > > > >
    > > > > > Cheers
    > > > > >
    > > > > >
    > > > > > Dan
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
    Chris Austin, Nov 1, 2004
    #8
  9. =?Utf-8?B?RGFuIE5hc2g=?=

    Tod1d Guest

    Hi Dan,

    Try this :
    Byte[] myBytes13 = {13};

    string myStr13 = System.Text.Encoding.ASCII.GetString(myBytes13);

    dbString.Replace(myStr13, "<br>")

    Sorry, I did not have time to test to see if this actually works.

    Tod Birdsall, MCP
    http://tod1d.blogspot.com

    "Dan Nash" <> wrote in message news:<>...
    > Hi guys
    >
    > Neither of those work. I think I need to actually put the ascii char 13, but
    > im not sure how to do it. In the db it looks like a little square box! It's
    > that I want to replace with <br>.
    >
    > Any ideas?
    >
    >
    > "Chris Austin" wrote:
    >
    > > Dan,
    > >
    > > I think you are looking for "\n".
    > >
    > > -Chris
    > > http://weblogs.austinspad.com/caustin
    > >
    > > "Dan Nash" <> wrote in message
    > > news:...
    > > > Lo,
    > > >
    > > > In a previous version of an app, I used replace to convert multiline text
    > > > boxes to something easier to put in a database, and then i used
    > > > replace(chr(13), "<br>") when i needed to show the data.
    > > >
    > > > I'm now working on a new version of this app, and im using C# / .NET.
    > > > Obviously I'm using the old database, but I cant find out how to do
    > > > replace(chr(13), "<br>").
    > > >
    > > > Basically, what's Chr(13) in C# :eek:)
    > > >
    > > > Cheers
    > > >
    > > >
    > > > Dan

    > >
    > >
    > >
     
    Tod1d, Nov 2, 2004
    #9
  10. "\n" is used in *nix systems. In DOS/Windows it should be "/r/n" I think.
    (Though most software expecially browsers should have no difference, I don't
    think it should be the case for database where data ought to be kept as it.

    P.S.: "/r" is carriage return, "/n" is newline. They carry hex code
    "0Dh"(chr(13)) and "0Ah"(chr(10)) respectively.
    P.S.: "/r" is used for Apple/Mac.

    "Dan Nash" <> ¦b¶l¥ó
    news: ¤¤¼¶¼g...
    > Hi guys
    >
    > Neither of those work. I think I need to actually put the ascii char 13,

    but
    > im not sure how to do it. In the db it looks like a little square box!

    It's
    > that I want to replace with <br>.
    >
    > Any ideas?
    >
    >
    > "Chris Austin" wrote:
    >
    > > Dan,
    > >
    > > I think you are looking for "\n".
    > >
    > > -Chris
    > > http://weblogs.austinspad.com/caustin
    > >
    > > "Dan Nash" <> wrote in message
    > > news:...
    > > > Lo,
    > > >
    > > > In a previous version of an app, I used replace to convert multiline

    text
    > > > boxes to something easier to put in a database, and then i used
    > > > replace(chr(13), "<br>") when i needed to show the data.
    > > >
    > > > I'm now working on a new version of this app, and im using C# / .NET.
    > > > Obviously I'm using the old database, but I cant find out how to do
    > > > replace(chr(13), "<br>").
    > > >
    > > > Basically, what's Chr(13) in C# :eek:)
    > > >
    > > > Cheers
    > > >
    > > >
    > > > Dan

    > >
    > >
    > >
     
    Lau Lei Cheong, Nov 2, 2004
    #10
  11. Good heavens! How about:

    char thirteen = (char) 13;

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    I get paid good money to
    solve puzzles for a living

    "Tod1d" <> wrote in message
    news:...
    > Hi Dan,
    >
    > Try this :
    > Byte[] myBytes13 = {13};
    >
    > string myStr13 = System.Text.Encoding.ASCII.GetString(myBytes13);
    >
    > dbString.Replace(myStr13, "<br>")
    >
    > Sorry, I did not have time to test to see if this actually works.
    >
    > Tod Birdsall, MCP
    > http://tod1d.blogspot.com
    >
    > "Dan Nash" <> wrote in message

    news:<>...
    > > Hi guys
    > >
    > > Neither of those work. I think I need to actually put the ascii char 13,

    but
    > > im not sure how to do it. In the db it looks like a little square box!

    It's
    > > that I want to replace with <br>.
    > >
    > > Any ideas?
    > >
    > >
    > > "Chris Austin" wrote:
    > >
    > > > Dan,
    > > >
    > > > I think you are looking for "\n".
    > > >
    > > > -Chris
    > > > http://weblogs.austinspad.com/caustin
    > > >
    > > > "Dan Nash" <> wrote in message
    > > > news:...
    > > > > Lo,
    > > > >
    > > > > In a previous version of an app, I used replace to convert multiline

    text
    > > > > boxes to something easier to put in a database, and then i used
    > > > > replace(chr(13), "<br>") when i needed to show the data.
    > > > >
    > > > > I'm now working on a new version of this app, and im using C# /

    ..NET.
    > > > > Obviously I'm using the old database, but I cant find out how to do
    > > > > replace(chr(13), "<br>").
    > > > >
    > > > > Basically, what's Chr(13) in C# :eek:)
    > > > >
    > > > > Cheers
    > > > >
    > > > >
    > > > > Dan
    > > >
    > > >
    > > >
     
    Kevin Spencer, Nov 2, 2004
    #11
  12. =?Utf-8?B?RGFuIE5hc2g=?=

    matoksoz

    Joined:
    Jul 19, 2007
    Messages:
    1
    char in c#

    vb 6.0
    Chr(13)

    c# equivalent is

    (char)13;

    Example;

    string xx= (char)13+ "hello"+(char)13;
     
    matoksoz, Jul 19, 2007
    #12
  13. =?Utf-8?B?RGFuIE5hc2g=?=

    Dudeman3000

    Joined:
    Feb 22, 2010
    Messages:
    1
    Chr(13) c# equivalent

    Char[] SplitCharacters = new Char[6];
    SplitCharacters[0] = ',';
    SplitCharacters[1] = (char)13;
    SplitCharacters[2] = ' ';
    SplitCharacters[3] = (char)10;
    SplitCharacters[4] = (char)11;
    SplitCharacters[5] = (char)12;
     
    Dudeman3000, Feb 22, 2010
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. crjunk
    Replies:
    2
    Views:
    16,916
    crjunk
    Aug 8, 2003
  2. Andi Twine
    Replies:
    3
    Views:
    571
    Natty Gur
    Jan 13, 2004
  3. ProJee
    Replies:
    3
    Views:
    459
    ProJee
    Nov 17, 2004
  4. MattB
    Replies:
    3
    Views:
    566
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Nov 19, 2004
  5. Frits JK

    problem sending chr(0)

    Frits JK, Jun 25, 2004, in forum: C++
    Replies:
    1
    Views:
    346
    Howard
    Jun 28, 2004
Loading...

Share This Page