I'm assuming that this is a C++ globally allocated character array. $bvar(&var,0) returns the array length, where as $bvar(&var,X) returns whatever is in that position within the array. character arrays and of the likes are null terminated "\0" or ASCII code 0. $bvar(&var,1-).text is the string literal from the contents of the array, which returns up to null termination.
With that in mind, during mIRC's WinSock processing, it has read x bytes until it finds an ASCII chr 13, chr 10 or both ($cr,$lf, or $crlf) since you've used the -n flag. Take this example below.
"abc<crlf>def<crlf>"
during it's scan, it finds "abc<crlf>" which has a length of 5, A,B,C,$cr,$lf. This is put into a globally allocated character array and removed from the WinSock buffer so what's left is "def<crlf>" for the next read. This character array needs to be able to fit the entire content of all 5 characters.
with the -n flag, you specify that you want to break at crlf, which is what it did, upon the return it replaces the end two characters with 0 clearing the ascii codes 13 and 10.
The string literal (not the array) $bvar(&var,1-).text IS correct in the return of "abc", as it reads up to null termination.
if you REALLY need no trailing termination (zero filled similar to overwriting the contents of a binvar with /bcopy -z) then you need to create a new array, and copy the contents you need into it.
Since you used &a, we'll make a new one and call it &b.
bcopy &b 1 &a 1 $calc($bfind(&a,1,0) - 1)
now with a sockwrite -n client
A:
$bvar(&a,0) = 2
$bvar(&a,1) = 0
$bvar(&a,2) = 0
B:
$bvar(&b,0) = 0
now with a sockwrite -n client Hi!
A:
$bvar(&a,0) = 5
$bvar(&a,1) = 72
$bvar(&a,2) = 105
$bvar(&a,3) = 33
$bvar(&a,4) = 0
$bvar(&a,5) = 0
B:
$bvar(&b,0) = 3
$bvar(&b,1) = 72
$bvar(&b,2) = 105
$bvar(&b,3) = 33
Note: If you're doing a sockread loop with checking $sockbr, don't forget to /bunset &b before you bcopy again, or you could use -z to zero fill, but then you'd be back in the same boat with trailing ASCII 0's
