Re: How is this conditional able to execute?




"Stephany Young" <noone@localhost> wrote in message
news:%23hNf834QFHA.3988@xxxxxxxxxxxxxxxxxxxxxxx
> What test are you using to determine that returndata.ToString = ""?
>
> Are you , for example, executing a:
>
> Console.Writeline("returndata.ToString = " & returndata.ToString)
>
> and getting the result:
>
> returndata.ToString =
>
> Your comment about returndata 'always' being 8193 bytes gives us the clue
> as what is happening.
>
> I suspect that returndata is padded with null characters (chr(0)).
>
> The Trim function (aka Microsoft.VisualBasic.Trim) only 'trims' leading
> and trailing Space characters.
>
> The String.Trim Method 'trims' leading and trailing whitespace characters.
> 'whitespace' comprises a number of characters including the null character
> (chr(0)).
>
> I think that if you change the line:
>
> Dim returndata As String = Trim(Encoding.UTF8.GetString(bytes))
>
> to
>
> Dim returndata As String = Encoding.UTF8.GetString(bytes).Trim()
>
> then the test will work correctly.

That doesn't work either. In some cases, bytes will come in as a zero byte
array with length 8193. Every element in that array will be zero.
returndata is assigned and its length becomes 8193 as well.


.



Relevant Pages

  • Re: How is this conditional able to execute?
    ... the non zero elements increase in the bytes array. ... >>> Your comment about returndata 'always' being 8193 bytes gives us the ... >>> I suspect that returndata is padded with null characters ). ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How is this conditional able to execute?
    ... > EXACT same results when you executed the EXACT same code. ... returndata still has a large length and value of ... >>> from the beginning and the 14 Null characters from the end which leaves ... >>> It is the Null character at the beginning that is causing your string to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How is this conditional able to execute?
    ... EXACT same results when you executed the EXACT same code. ... 'trimming' of the Null characters does actually work as expected on your ... returndata still has a large length and value of ... >> It is the Null character at the beginning that is causing your string to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How is this conditional able to execute?
    ... Are you, for example, executing a: ... I suspect that returndata is padded with null characters ). ... Dim returndata As String = Trim) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: question on "get document" method in FrontPage RPC
    ... Where is the byte array appended to? ... Based on the number of bytes in the returnData, ... > Microsoft Product Support Services ... > private string GetDocument(string url, ...
    (microsoft.public.sharepoint.portalserver.development)