Can I create from a Bitmap an a specification ? #232
Replies: 3 comments 2 replies
-
@camilotorres can you please be more specific with your question? |
Beta Was this translation helpful? Give feedback.
-
Having a bitmap you can see which fields of the spec are present in the message. Here is the test code that you can use to see set bits in your bitmap: package iso8583_test
import (
"fmt"
"testing"
"github.com/moov-io/iso8583/encoding"
"github.com/moov-io/iso8583/field"
"github.com/moov-io/iso8583/prefix"
)
func TestBitmap(t *testing.T) {
bitmapSpec := &field.Spec{
Length: 8,
Description: "Bitmap",
Enc: encoding.BytesToASCIIHex,
Pref: prefix.Hex.Fixed,
}
bitmap := field.NewBitmap(bitmapSpec)
_, err := bitmap.Unpack([]byte("F0040000200000000000000000000000"))
if err != nil {
t.Fatal(err)
}
bits, _ := bitmap.String()
fmt.Printf("bits of the bitmap: %s\n", bits)
for i := 1; i <= bitmap.Len(); i++ {
if bitmap.IsSet(i) {
fmt.Printf("bit %d is set\n", i)
}
}
} The output is:
So, you can see that the message for this bitmap has the following fields: 1,2,3,4,14,35. But that's all you can get having only the bitmap. You need a full message spec (at least you need to describe fields that are in the message) to properly decode the message. If you don't have a document that in details describes the field formats, then I would suggest you try this one: https://github.com/moov-io/iso8583/blob/master/specs/spec87ascii.go#L12 as you may see I copied bitmap spec from that file. If you can provide more details about the data you have, together we may try to guess what the spec is. I'll also better understand what you want to achieve using the iso8583 package. |
Beta Was this translation helpful? Give feedback.
-
Excelent thanks !! |
Beta Was this translation helpful? Give feedback.
-
Can I create a specification from a Bitmap ?
Beta Was this translation helpful? Give feedback.
All reactions