Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datamatrix: first FNC1 as ascii 232 #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion datamatrix/encoder/high_level_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
HighLevelEncoder_LATCH_TO_BASE256 = 231

// FNC1 Codeword
// HighLevelEncoder_FUNC1 = 232
HighLevelEncoder_FUNC1 = 232

// Structured Append Codeword
// HighLevelEncoder_STRUCTURED_APPEND = 233
Expand Down Expand Up @@ -118,6 +118,11 @@ func EncodeHighLevel(msg string, shape SymbolShapeHint, minSize, maxSize *gozxin
context.SetSymbolShape(shape)
context.SetSizeConstraints(minSize, maxSize)

if strings.HasPrefix(msg, "\u00e8") {
context.WriteCodeword(HighLevelEncoder_FUNC1)
context.pos += 1
}

if strings.HasPrefix(msg, HighLevelEncoder_MACRO_05_HEADER) &&
strings.HasSuffix(msg, HighLevelEncoder_MACRO_TRAILER) {
context.WriteCodeword(HighLevelEncoder_MACRO_05)
Expand Down
10 changes: 10 additions & 0 deletions datamatrix/encoder/high_level_encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,14 @@ func TestEncodeHighLevel(t *testing.T) {
if !reflect.DeepEqual(b, expect) {
t.Fatalf("EncodeHighLevel = %v, expect %v", b, expect)
}

str = "\u00e8a"
b, e = EncodeHighLevel(str, shape, nil, nil)
expect = []byte{232, 98, 129}
if e != nil {
t.Fatalf("EncodeHighLevel returns error: %v", e)
}
if !reflect.DeepEqual(b, expect) {
t.Fatalf("EncodeHighLevel = %v, expect %v", b, expect)
}
}