type: Fixed FromString encoding for ASCII.

- We were appending a newline rather than NUL.
pull/3/head
Dustin Oprea 2018-06-10 18:45:34 -04:00
parent d79470a4f4
commit f998692895
2 changed files with 2 additions and 2 deletions

View File

@ -757,7 +757,7 @@ func (tt TagType) FromString(valueString string) (value interface{}, err error)
if tt.tagType == TypeByte {
return []byte(valueString), nil
} else if tt.tagType == TypeAscii {
return fmt.Sprintf("%s\n", valueString), nil
return fmt.Sprintf("%s\000", valueString), nil
} else if tt.tagType == TypeShort {
n, err := strconv.ParseUint(valueString, 10, 16)
log.PanicIf(err)

View File

@ -215,7 +215,7 @@ func TestTagType_FromString_Ascii(t *testing.T) {
value, err := tt.FromString("abc")
log.PanicIf(err)
if reflect.DeepEqual(value, "abc\n") != true {
if reflect.DeepEqual(value, "abc\000") != true {
t.Fatalf("ASCII value not correct: [%s]", value)
}
}