Coder Social home page Coder Social logo

can't send empty string about osc HOT 1 OPEN

scgolang avatar scgolang commented on June 3, 2024
can't send empty string

from osc.

Comments (1)

vlappa avatar vlappa commented on June 3, 2024

I think I found the cause:

SendTo calls Bytes method on packet (a osc message)
https://github.com/scgolang/osc/blob/master/udp.go#L106C29-L106C29

Bytes method of message calls Bytes method for arguments, in this case a String
https://github.com/scgolang/osc/blob/master/message.go#L58

https://github.com/scgolang/osc/blob/master/argument.go#L239

Bytes method of String calls ToBytes. ToBytes returns []byte{} when len(string) == 0
https://github.com/scgolang/osc/blob/master/osc.go#L46

Then Pad doesn't append any null character (it isn't called)
https://github.com/scgolang/osc/blob/master/osc.go#L55

ToBytes is also used for msg.Address and BundleTag :
https://github.com/scgolang/osc/blob/master/message.go#L54
https://github.com/scgolang/osc/blob/master/bundle.go#L79

Both can't be empty according to the OSC specs I think*.

And a empty string is tested:
https://github.com/scgolang/osc/blob/master/osc_test.go#L14
It expects: []byte{}
but in this case it should be the following I think:
[]byte{0,0,0,0}

From the specs: osc string = A sequence of non-null ASCII characters followed by a null, followed by 0-3 additional null characters

(
Not related to this issue I think, but ReadString has a similar way of handling empty strings
https://github.com/scgolang/osc/blob/master/osc.go#L71
)

Looking at the gosc library, it checks if a string has "\x00" as suffix and adds it when it doesn't have any, as is the case with a empty string.
https://github.com/loffa/gosc/blob/master/writer.go#L104

I think something similar is done in the go-osc library:
https://github.com/hypebeast/go-osc/blob/master/osc/osc.go#L1027

from osc.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.