-
Extra Long strings!
Hey guys!
I have a stream that is spitting out an array of bytes (length of 1024).
well, lets say the array contains the word "Hello" when i convert the array
into a string using the Encoding.ASCII it seems that the string's length is
als 1024. the funny thing is, that when i hover over the string, i see this
"Hello , with the right " character missing. it is my assumption that when
i convert it from a byte array into a string, it also converts all of the
bytes that are 0 into its ASCII string equivilent, which is supposed to be
null. i was just wondering if there was any way for me to get rid of those
0's in the byte array or the "null" characters in the string so i can have a
string with the correct value.
and if anyone is wondering, i did try trimming it, but that does not seem to
work. something that is also very weird that if i try to view a value in the
immidiate window, i see tha value that i expect, but in the IDE editor, its
got the extra stuff....
thanks!
Vinny
-
Re: Extra Long strings!
I haven't played with it, but off the top of my head, you can find the first
occurance of a null character and get the Left (or SubString) up to that
position - 1.
-Rob
"Vinny" <vad@nospam@stgroup.net> wrote:
>Hey guys!
>
>I have a stream that is spitting out an array of bytes (length of 1024).
>well, lets say the array contains the word "Hello" when i convert the array
>into a string using the Encoding.ASCII it seems that the string's length
is
>als 1024. the funny thing is, that when i hover over the string, i see this
>"Hello , with the right " character missing. it is my assumption that
when
>i convert it from a byte array into a string, it also converts all of the
>bytes that are 0 into its ASCII string equivilent, which is supposed to
be
>null. i was just wondering if there was any way for me to get rid of those
>0's in the byte array or the "null" characters in the string so i can have
a
>string with the correct value.
>
>and if anyone is wondering, i did try trimming it, but that does not seem
to
>work. something that is also very weird that if i try to view a value in
the
>immidiate window, i see tha value that i expect, but in the IDE editor,
its
>got the extra stuff....
>
>thanks!
>
>Vinny
>
>
-
Re: Extra Long strings!
Vinny,
Rob has a good memory! It is indeed what must be done. I use the same
method when I read data from a C/C++ DLL through a managed structure.
Pat
"Rob Teixeira" <RobTeixeira@@msn.com> wrote:
>
>
>I haven't played with it, but off the top of my head, you can find the first
>occurance of a null character and get the Left (or SubString) up to that
>position - 1.
>
>-Rob
>
>"Vinny" <vad@nospam@stgroup.net> wrote:
>>Hey guys!
>>
>>I have a stream that is spitting out an array of bytes (length of 1024).
>>well, lets say the array contains the word "Hello" when i convert the array
>>into a string using the Encoding.ASCII it seems that the string's length
>is
>>als 1024. the funny thing is, that when i hover over the string, i see
this
>>"Hello , with the right " character missing. it is my assumption that
>when
>>i convert it from a byte array into a string, it also converts all of the
>>bytes that are 0 into its ASCII string equivilent, which is supposed to
>be
>>null. i was just wondering if there was any way for me to get rid of those
>>0's in the byte array or the "null" characters in the string so i can have
>a
>>string with the correct value.
>>
>>and if anyone is wondering, i did try trimming it, but that does not seem
>to
>>work. something that is also very weird that if i try to view a value in
>the
>>immidiate window, i see tha value that i expect, but in the IDE editor,
>its
>>got the extra stuff....
>>
>>thanks!
>>
>>Vinny
>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks