473,835 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question for Encoding.ASCII. GetString

Hi guys,

I'm integrating our systems into another system which returns a
response code after doing a POST

Byte[] responseData = objWebClient.Up loadValues(post To,
objFormPost);
string retVal = Encoding.ASCII. GetString(respo nseData);

The retVal looks like
<\0C\0o\0n\0t\0 a\0c\0t\0I\0d\0 >\01\00\04\00\0 9\02\03\02\05\0 8\05\0<
\0/\0C\0o\0n\0t\0a \0c\0t\0I\0d\0> \0

When you use the VisualStudio HTML viewer or set it to an
HTML.innerHTML then the value is displayed fine
10409232585

How can I retrieve '10409232585' using code? I tried HtmlDecode with
no lock.

Thanks
M.
Aug 26 '08 #1
3 1643
On Aug 26, 4:56*pm, mazdotnet <maflat...@gmai l.comwrote:
Hi guys,

I'm integrating our systems into another system which returns a
response code after doing a POST

Byte[] responseData = objWebClient.Up loadValues(post To,
objFormPost);
string retVal = Encoding.ASCII. GetString(respo nseData);

The retVal looks like
<\0C\0o\0n\0t\0 a\0c\0t\0I\0d\0 >\01\00\04\00\0 9\02\03\02\05\0 8\05\0<
\0/\0C\0o\0n\0t\0a \0c\0t\0I\0d\0> \0

When you use the VisualStudio HTML viewer or set it to an
HTML.innerHTML then the value is displayed fine
10409232585

How can I retrieve '10409232585' using code? I tried HtmlDecode with
no lock.

Thanks
M.
Sorry one more thing to add. When I do it like

string v = "<\0C\0o\0n\0t\ 0a\0c\0t\0I\0d\ 0>
\01\00\04\00\09 \02\03\02\05\08 \05\0<\0/\0C\0o\0n\0t\0a \0c\0t\0I\0d\0>
\0";
Response.Write( v);

It prints '10409232585'

What's happening? Can someone please help?

Thanks
M
Aug 26 '08 #2
"mazdotnet" <ma*******@gmai l.comwrote in message
news:0a******** *************** ***********@l64 g2000hse.google groups.com...
Hi guys,

I'm integrating our systems into another system which returns a
response code after doing a POST

Byte[] responseData = objWebClient.Up loadValues(post To,
objFormPost);
string retVal = Encoding.ASCII. GetString(respo nseData);

The retVal looks like
<\0C\0o\0n\0t\0 a\0c\0t\0I\0d\0 >\01\00\04\00\0 9\02\03\02\05\0 8\05\0<
\0/\0C\0o\0n\0t\0a \0c\0t\0I\0d\0> \0

When you use the VisualStudio HTML viewer or set it to an
HTML.innerHTML then the value is displayed fine
10409232585

How can I retrieve '10409232585' using code? I tried HtmlDecode with
no lock.
Looks to me as though responseData is Unicode not ASCII.
Try:-

string retVal = Encoding.Unicod e.GetString(res ponseData);


--
Anthony Jones - MVP ASP/ASP.NET
Aug 26 '08 #3
On Aug 26, 5:19*pm, "Anthony Jones" <A...@yadayaday ada.comwrote:
"mazdotnet" <maflat...@gmai l.comwrote in message

news:0a******** *************** ***********@l64 g2000hse.google groups.com...


Hi guys,
I'm integrating our systems into another system which returns a
response code after doing a POST
Byte[] responseData = objWebClient.Up loadValues(post To,
objFormPost);
string retVal = Encoding.ASCII. GetString(respo nseData);
The retVal looks like
<\0C\0o\0n\0t\0 a\0c\0t\0I\0d\0 >\01\00\04\00\0 9\02\03\02\05\0 8\05\0<
\0/\0C\0o\0n\0t\0a \0c\0t\0I\0d\0> \0
When you use the VisualStudio HTML viewer or set it to an
HTML.innerHTML then the value is displayed fine
10409232585
How can I retrieve '10409232585' using code? I tried HtmlDecode with
no lock.

Looks to me as though responseData is Unicode not ASCII.
Try:-

string retVal = Encoding.Unicod e.GetString(res ponseData);

--
Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -

- Show quoted text -
Thank you. It worked.
Maz
Aug 26 '08 #4

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

Similar topics

0
1672
by: Milan Goellner | last post by:
greetings, i am completely new to c# and i'm looking to write a littel util to extract snmp information from cisco hardware for starters. i have found some sample code helping me along my way but i'm now looking at a piece of code which extract the usefull stuff from the responds and cuts away the useless. this code i don't understand, could someone please tell me how it works, short and very simple :) ?
1
1552
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to get it to recieve only one line of data, but the next one i send to it wont be printed like the 1st one. I had a listner running in a thread, does anyone have a simple listner code example that would show how to have a tcplistner thread running...
4
1534
by: Martin Fletcher | last post by:
when I execute dim strTEMP_DATA as string strTEMP_DATA = Encoding.ASCII.GetString(rBuffer).ToString I alway get a string without the closing quote. I see this in the 'Autos' window, I also see it when I hoover my mouse over the strTEMP_DATA above. An example would be: It looks like "test
3
1039
by: Tiraman | last post by:
hi, i build some client server application which work with sockets (System.Net.Sockets) and when i m sending data (Hebrew text) from the server to the client and backward i m getting the text not so well (gibberish or some thing not readable) any idea ?
3
6059
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 is I never know in advance what size the string will be. When I call Encoding.ASCII.GetString I need to specify the size. If I set it to ret.Length as above then in the debugger I can see msg is the full 1024 bytes (0 padded at the end...
3
1922
by: Eric Marthinsen | last post by:
Hello- I'm trying to create a console app that will accept an incoming HTTP request and output the information of the request to the console. The code is pretty simple - here's what it looks like: TcpListener listenter = new TcpListener(IPAddress.Any, 8000); listenter.Start();
4
14333
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 is a long string contain string("ABC") and many '0',
9
4151
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string. What am I doing wrong? Dim plainText As String plainText = "t═e" Dim plainTextBytes() As Byte Dim enc As Encoding = Encoding.ASCII plainTextBytes = enc.GetBytes(plainText)
21
1520
by: Markgoldin | last post by:
I am working on a program that creates a few TCP listenrs to accept data from non .net processes. Each listener listens in its own thread. I am using Thread.Sleep(1000) to let other threads work. Here is my code: tcpl = new TcpListener(ipe); TcpClient tcpc = tcpl.AcceptTcpClient(); while (true) { // get data
0
9808
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9652
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10561
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,...
0
9346
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
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
6966
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4434
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
3995
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3089
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.