mirror of
https://github.com/jwetzell/osc-go.git
synced 2026-09-08 06:59:01 +00:00
rework send string
This commit is contained in:
@@ -174,17 +174,13 @@ func argsToBuffer(args []OSCArg) []byte {
|
|||||||
func readOSCString(bytes []byte) (string, []byte) {
|
func readOSCString(bytes []byte) (string, []byte) {
|
||||||
//TODO(jwetzell): add error handling
|
//TODO(jwetzell): add error handling
|
||||||
oscString := ""
|
oscString := ""
|
||||||
stringFinished := false
|
|
||||||
stringEndIndex := 0
|
stringEndIndex := 0
|
||||||
remainingBytes := []byte{}
|
|
||||||
|
|
||||||
for index, byteIn := range bytes {
|
for index, byteIn := range bytes {
|
||||||
if !stringFinished {
|
if byteIn == 0 {
|
||||||
if byteIn == 0 {
|
oscString = string(bytes[0:index])
|
||||||
oscString = string(bytes[0:index])
|
stringEndIndex = index + 1
|
||||||
stringEndIndex = index + 1
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +190,7 @@ func readOSCString(bytes []byte) (string, []byte) {
|
|||||||
stringEndIndex = stringEndIndex + stringPadding
|
stringEndIndex = stringEndIndex + stringPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
remainingBytes = bytes[stringEndIndex:]
|
remainingBytes := bytes[stringEndIndex:]
|
||||||
|
|
||||||
return oscString, remainingBytes
|
return oscString, remainingBytes
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user