473,703 Members | 3,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String Builder, appending carriage return

Hi,

I am trying to append a carriage return to my string using the string
builder class, but when I do this the string ends up containing "13".
I tried this multiple ways like so

sb->Append('\r') ;

and also

sb->Append(System: :Windows::Forms ::Keys::Enter);

and lastly i tried

sb->Append((char)1 3);

I also tried that last one without the char type casting and my string
still contains 13 instead of a code for carriage return. Any ideas??

Apr 23 '06 #1
11 8458
I just realized this function is expecting a string, so a character
constant will not work. if you do

sb->Append("\r") ;

it will append a carriage return code.

Apr 23 '06 #2
The Rain,

A cariage return are two codes, A carriage "\c" and a return "\r"
ASC 13 10

I hope this help

Cor
"TheRain" <co**********@g mail.com> schreef in bericht
news:11******** *************@g 10g2000cwb.goog legroups.com...
I just realized this function is expecting a string, so a character
constant will not work. if you do

sb->Append("\r") ;

it will append a carriage return code.

Apr 24 '06 #3
> A cariage return are two codes, A carriage "\c" and a return "\r"
ASC 13 10


or try:
sb.Append(Envir onment.NewLine) ;

Markus
Apr 24 '06 #4
Cor Ligthert [MVP] <no************ @planet.nl> wrote:
A cariage return are two codes, A carriage "\c" and a return "\r"
ASC 13 10


No, that's carriage return and line feed. Carriage return ("\r") is 13,
and line feed ("\n") is 10. The two of them are used together for the
Windows line ending.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 24 '06 #5
TheRain <co**********@g mail.com> wrote:
I just realized this function is expecting a string, so a character
constant will not work.


There *is* a method which accepts a char though. Perhaps the problem is
that it's expecting a .NET char (i.e. Unicode) rather than a C/C++
char. Did you try:

sb->Append (L'\r');

?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 24 '06 #6
hey... I just started messing with .net so I'm not even sure what that
L does.. is that some kind of typecasting?? I keep seeing S used like
this in MSDN articles. Anyway, I just attempted the sb->Append(L'r') ;
and it still gives me 13 instead at the output.

thanks for all of the thoughts and comments, maybe some others will
find this useful as well.

Apr 24 '06 #7
As an aside, "\n" is the Unix equivalent. No CR.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Cor Ligthert [MVP] <no************ @planet.nl> wrote:
A cariage return are two codes, A carriage "\c" and a return "\r"
ASC 13 10


No, that's carriage return and line feed. Carriage return ("\r") is 13,
and line feed ("\n") is 10. The two of them are used together for the
Windows line ending.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 24 '06 #8
TheRain <co**********@g mail.com> wrote:
hey... I just started messing with .net so I'm not even sure what that
L does.. is that some kind of typecasting?? I keep seeing S used like
this in MSDN articles.
I *think* S is used for a managed string, but to be honest I don't know
about managed chars. I don't know a lot about MC++ :(
Anyway, I just attempted the sb->Append(L'r') ;
and it still gives me 13 instead at the output.


Right - I think you'd have to find out what the equivalent of a .NET
char is in MC++ to work it out for sure.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 24 '06 #9
Hello, TheRain!

T> I am trying to append a carriage return to my string using the string
T> builder class, but when I do this the string ends up containing "13".
T> I tried this multiple ways like so

If you're under .NET you can do sb->AppendLine("so metext");
Environment.New Line will be appended after the text.

AppenLine internally uses this.Append(Env ironment.NewLin e);

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Apr 25 '06 #10

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

Similar topics

2
2134
by: Karuppasamy | last post by:
Hi I am using a variable of StringBuilder to form a string. After appending a string of value like this {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Verdana;}}
2
5104
by: José Joye | last post by:
Hello, I was wondering if there is a method that exists to replace multi-spaces within a string with single-space. eg: "12 3 4 56" --> "12 3 4 56" I think this could be done by looking at each char within a loop and copying the char to a stringBuilder instance if current and previous char are not spaces...
12
2451
by: Tee | last post by:
String Builder & String, what's the difference. and when to use which ? Thanks.
2
2357
by: P K | last post by:
Hi, I have around 30 fields on a screen each one of which I need to validate. The idea was to have a set of messages to be displayed for all the posiible errors instead of having to show a single message at a time. For this I was using a string builder and appending all the text to it after each validation. This process slowed down the system and at a point I got the out of memory exception. Would a string builder consitsiting of 20-30...
2
40020
by: sean | last post by:
Can anyone tell me how to add a carriage return to a string using vb.net? I need to add two strings with a carrage return together and post to an email message body ie: This gives me an error: string3 = string1 & vbcrlf & string2 mail.body = string3
18
2161
by: ILCSP | last post by:
Hi, I just started learning Visual Basic (VB.NET 03) and I need to do this small program that will read a text file we get from another company that has survey data, parse it and flatten it out and make single strings out of the records in it. The major difference between this space delimited file from the many examples in these groups is that the data is not presented horizontally, but vertically. You can see an example below. What I...
26
3190
by: Hardy Wang | last post by:
Hi all, I know it is better to handle large string with a StringBuilder, but how does StringBuilder class improve the performance in the background? Thanks! -- WWW: http://hardywang.1accesshost.com ICQ: 3359839 yours Hardy
7
1432
by: simonZ | last post by:
I have array variable transfer: String transfer which has some data Than I would like to convert this data into string: Which way is more efficient: StringBuilder rezult=new StringBuilder(); for (int i = 0; i < transfer.Length; i++) {
13
7956
by: xzzy | last post by:
None of the following properly do the VB.net double quote conversion because all of the following in csharp convert to \" instead of just a double quote: " I have tried: char myDoubleQuote = (char)34; string myDoubleQuote = "" + (char)34;
0
8759
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9252
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4433
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3125
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.