Question for Encoding.ASCII.GetString

  • Thread starter Thread starter mazdotnet
  • Start date Start date
M

mazdotnet

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 = Encoding.ASCII.GetString(responseData);

The retVal looks like
<\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

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.
 
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 = Encoding.ASCII.GetString(responseData);

The retVal looks like
<\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

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
 
mazdotnet said:
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 = Encoding.ASCII.GetString(responseData);

The retVal looks like
<\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

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.Unicode.GetString(responseData);
 
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 = Encoding.ASCII.GetString(responseData);
The retVal looks like
<\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
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.Unicode.GetString(responseData);

Thank you. It worked.
Maz
 
Back
Top