473,473 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GetString and byte data

Given the following:

string x = System.Text.Encoding.Default.GetString(buffer);
x = x.Replace("\r\n", "\r");

If the buffer contains 13 and 10 (2 bytes), can someone please tell me
why the second line cant find and replace? \r\n is supposed to be
equivalent to 13,10 arent they? Im trying to strip out the newline (10)
character.

Nov 17 '05 #1
1 1993
Hi Scott,
I just ran that piece of code and it worked just like I expected it to. I
tried:

byte[] buffer;

buffer = System.Text.Encoding.Default.GetBytes("hello\r\nho w are you?");

string x = System.Text.Encoding.Default.GetString(buffer);
x = x.Replace("\r\n", "\r");

If you look at the contents of buffer you can see byte 13 and 10, after
replacing byte 10 is not longer there in string x.

Mark.
"sc**********@yahoo.com" wrote:
Given the following:

string x = System.Text.Encoding.Default.GetString(buffer);
x = x.Replace("\r\n", "\r");

If the buffer contains 13 and 10 (2 bytes), can someone please tell me
why the second line cant find and replace? \r\n is supposed to be
equivalent to 13,10 arent they? Im trying to strip out the newline (10)
character.

Nov 17 '05 #2

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

Similar topics

2
by: Paul K | last post by:
I've run into a problem using this method that I have been able to work around, but I think that there is a more elegant way. I create an array of 256 bytes and use the SHBrowseForFolders API...
4
by: Simon | last post by:
Hi, Can anyone explain the following behaviour? private static int BUFFER_SIZE = 1024; private byte Buffer = new byte; private Encoding ASCII = Encoding.ASCII; private...
3
by: GTi | last post by:
I have a SQL database and some fields may be null. This will trow an exeption: string s=new string; s=String.Format("{0}",myReader.GetString(1)); s=String.Format("{0}",myReader.GetString(2));...
0
by: iMonkey | last post by:
I have tried the following to convert an encrypted byte() into a string to write it to a database: Dim encoding as new UTF8Encoding() Dim EncNum as String = encoding.GetString(...
1
by: PrettySneaky | last post by:
Like the subject said. I have an byte array and want to save them in a text file with UTF8 encoding. However when an element in the byte array is above 127 the GetString method ignores the value...
3
by: devgrt | last post by:
C#: I have a buffer that is populated with char data from a DLL: byte ret = new byte; I want to convert to a C# string: string msg = Encoding.ASCII.GetString(ret, 0, ret.Length); The problem...
4
by: cok | last post by:
Hi, All I have a question about Encoding.ASCII.GetString. I want convert a byte array to a string, I use Encoding.ASCII.GetString(byteArray) (byteArray is something like ) but the retult...
1
by: jason.pileski | last post by:
I'm converting an asp.net 1.1 app to 2.0 and am having difficulty determining why ASCIIEncoding.GetString returns a different value in ..NET 2.0 than 1.1. The code is simple but I can't locate the...
3
by: mazdotnet | last post by:
Hi guys, I'm integrating our systems into another system which returns a response code after doing a POST Byte responseData = objWebClient.UploadValues(postTo, objFormPost); string retVal =...
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
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
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.