473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

C# equiv of Chr(13)

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# :o)

Cheers
Dan
Nov 18 '05 #1
10 17715
Dan,

I think you are looking for "\n".

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

"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan

Nov 18 '05 #2
Try System.Environment.NewLine

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan

Nov 18 '05 #3
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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan


Nov 18 '05 #4
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/de...terescapes.asp

HTH

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

"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:38**********************************@microsof t.com...
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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan


Nov 18 '05 #5
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/de...terescapes.asp

HTH

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

"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:38**********************************@microsof t.com...
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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
> 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# :o)
>
> Cheers
>
>
> Dan


Nov 18 '05 #6
in c#

"\r" = chr(13)
"\n" = chr(10)
mystring.Replace("\r","<br>");

-- bruce (sqlwork.com)
"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan

Nov 18 '05 #7
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" <da*@musoswire.co.uk> wrote in message
news:FB**********************************@microsof t.com...
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/de...terescapes.asp
HTH

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

"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:38**********************************@microsof t.com...
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" <da*@musoswire.co.uk> wrote in message
> news:F3**********************************@microsof t.com...
> > 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# :o)
> >
> > Cheers
> >
> >
> > Dan
>
>
>


Nov 18 '05 #8
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" <da*@musoswire.co.uk> wrote in message news:<38**********************************@microso ft.com>...
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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan


Nov 18 '05 #9
"\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" <da*@musoswire.co.uk> ¦b¶l¥ó
news:38**********************************@microsof t.com ¤¤¼¶¼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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
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# :o)

Cheers
Dan


Nov 18 '05 #10
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" <no*****@netsalad.com> wrote in message
news:94**************************@posting.google.c om...
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" <da*@musoswire.co.uk> wrote in message

news:<38**********************************@microso ft.com>...
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" <da*@musoswire.co.uk> wrote in message
news:F3**********************************@microsof t.com...
> 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# :o)
>
> Cheers
>
>
> Dan

Nov 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Eddie B. | last post by:
Does anyone know how to do Chr$(13) in .NET? Thanks, Eddie
6
by: C L Humphreys | last post by:
Hi, I'm trying to concatenate address fields and insert a LF&CR after each line. The SQL I use is based on select address1 & chr(10) & chr(13)& address2 & chr(10) & chr(13)& address3 & ...
1
by: jdph40 | last post by:
I am trying to enter text to look like paragraphs in a text box on a report, making it look like a memo. I enter (Chr$(13) & Chr$(10) & Chr$(10)) to insert a carriage return and 2 line breaks, but...
2
by: lauren quantrell | last post by:
Has anyone cunstructed a function to remove multiple carriage returns and replace it with a single return? Replace(mytext, Chr(13) & Chr(10) & Chr(13) & Chr(10), Chr(13) & Chr(10)) ... only...
2
by: MLH | last post by:
I run the following command in main menu form open event code... Me!MainMenuLabel.Caption = DLookup("", "qryAdminList") & Chr$(10) & Chr$(13) & DLookup("", "qryAdminList") & Chr$(10) & Chr$(13)...
3
by: Alberto | last post by:
In a application in visual basic 6 I had chr$(13). How can I get the same value in C#? Thank you
2
by: crjunk | last post by:
I have the following code in my web page. Dim tmpReplace As String 'Giving tmpReplace the value from the textbox on the webform. tmpReplace = txtComments.Text.Trim 'Prevents report from...
1
by: Felix | last post by:
We have a problem with the Chr(13) and WebServices (we are using VB.NET 2003). If we have a string that contains the Chr(13) and the Chr(10) (just the vbCrLf characters) and we pass it through a...
5
by: Computer Guru | last post by:
I have a form I'm using as a dialog box. It has default text that is two paragraphs. It has a function setText(byval text as string) that specifies the text in the read-only textbox that's on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.