K Karl Matzinger Member Licensed User Mar 27, 2018 #1 I'm confused: Bytearray from GetBlob (SQL) has negativ values buffer=cCursor2.GetBlob("vBlob") something like: -119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,-68,0,0,2,-87,8,6,0,0,0,94,.... I want to tranfer the blob via json and there is service (vb.net) to handle the json. But it can't handle negative Bytes. What am I doing wrong? Or what is the best way to transfer blobs via json?
I'm confused: Bytearray from GetBlob (SQL) has negativ values buffer=cCursor2.GetBlob("vBlob") something like: -119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,-68,0,0,2,-87,8,6,0,0,0,94,.... I want to tranfer the blob via json and there is service (vb.net) to handle the json. But it can't handle negative Bytes. What am I doing wrong? Or what is the best way to transfer blobs via json?
OliverA Expert Licensed User Longtime User Mar 27, 2018 #2 1) Base64 using StringUtils B4X: Dim su as StringUtils Dim base64Buffer As String = su.EncodeBase64(Buffer) 2) Hex using ByteConverter B4X: Dim bc as ByteConverter Dim hexBuffer as String = bc.HexFromBytes(Buffer) For JSON, pick #1 (#2 just showing another way). Upvote 0
1) Base64 using StringUtils B4X: Dim su as StringUtils Dim base64Buffer As String = su.EncodeBase64(Buffer) 2) Hex using ByteConverter B4X: Dim bc as ByteConverter Dim hexBuffer as String = bc.HexFromBytes(Buffer) For JSON, pick #1 (#2 just showing another way).
K Karl Matzinger Member Licensed User Mar 27, 2018 #3 Karl Matzinger said: I'm confused: Bytearray from GetBlob (SQL) has negativ values buffer=cCursor2.GetBlob("vBlob") something like: -119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,-68,0,0,2,-87,8,6,0,0,0,94,.... I want to tranfer the blob via json and there is service (vb.net) to handle the json. But it can't handle negative Bytes. What am I doing wrong? Or what is the best way to transfer blobs via json? Click to expand... I think this is working - first test are good: seems to bee a signed byte - the following should convert to unsigned-byte (for ms sql server blobs) IIf(i < 0, i + 256, i) Upvote 0
Karl Matzinger said: I'm confused: Bytearray from GetBlob (SQL) has negativ values buffer=cCursor2.GetBlob("vBlob") something like: -119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,2,-68,0,0,2,-87,8,6,0,0,0,94,.... I want to tranfer the blob via json and there is service (vb.net) to handle the json. But it can't handle negative Bytes. What am I doing wrong? Or what is the best way to transfer blobs via json? Click to expand... I think this is working - first test are good: seems to bee a signed byte - the following should convert to unsigned-byte (for ms sql server blobs) IIf(i < 0, i + 256, i)
K Karl Matzinger Member Licensed User Mar 27, 2018 #4 @OliverA. Thanks - will try it tomorror... Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2018 #5 B4X: Dim ub(buffer.Length) As Int For i = 0 to buffer.Length - 1 ub(i) = Bit.And(0xFF, buffer(i)) Next Upvote 0
B4X: Dim ub(buffer.Length) As Int For i = 0 to buffer.Length - 1 ub(i) = Bit.And(0xFF, buffer(i)) Next
K Karl Matzinger Member Licensed User Apr 3, 2018 #6 Erel said: B4X: Dim ub(buffer.Length) As Int For i = 0 to buffer.Length - 1 ub(i) = Bit.And(0xFF, buffer(i)) Next Click to expand... tx works great Upvote 0
Erel said: B4X: Dim ub(buffer.Length) As Int For i = 0 to buffer.Length - 1 ub(i) = Bit.And(0xFF, buffer(i)) Next Click to expand... tx works great