-
Notifications
You must be signed in to change notification settings - Fork 25
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
UTF8 encoding is lost #729
Labels
bug
Something isn't working
Milestone
Comments
orinem
added a commit
to orinem/mps
that referenced
this issue
Nov 17, 2022
…tring for CIRAChannel's sendBuffer.
3 tasks
orinem
added a commit
to orinem/mps
that referenced
this issue
Nov 17, 2022
…tring for CIRAChannel's sendBuffer.
orinem
added a commit
to orinem/mps
that referenced
this issue
Nov 18, 2022
…tring for CIRAChannel's sendBuffer.
3 tasks
orinem
added a commit
to orinem/mps
that referenced
this issue
Nov 22, 2022
…tring for CIRAChannel's sendBuffer. Added test for CIRAChannel writeData() binary path
orinem
added a commit
to orinem/mps
that referenced
this issue
Nov 22, 2022
…tring for CIRAChannel's sendBuffer Added test for CIRAChannel writeData() binary path
matt-primrose
pushed a commit
that referenced
this issue
Nov 22, 2022
…endBuffer Added test for CIRAChannel writeData() binary path
Repository owner
moved this from 👀 In review
to ✅ Done
in Feature Backlog
Nov 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug 🪲
When using an API that takes a character string, for example creating an alarm, the API will fail.
To Reproduce 🪜
Try to create an alarm named FooÀ.
Expected behavior
The alarm should be created and displayed correctly
AMT Device (please complete the following information): 🖥️
Service Deployment (please complete the following information): ⛈️
Additional context
Although the string sent to the device is UTF8 encoded into a Buffer in HttpHandler.wrapIt(), it implicitly gets decoded when appended to the message string since the default parameter to Buffer.toString() is 'utf8'.
In addition, the length of the javascript string is used, rather than the length of the UTF8 encoded string.
Although inefficient, the easiest workaround is to explicitly convert back from Buffer using Buffer.toString('binary'). When eventually converted to a buffer, the string returned from wrapIt() is treated as 'binary' so no further changes are necessary.
Making the above changes allows the alarm to be created, but it displays incorrectly. This is because the xml parser ignores the encoding. A very inefficient fix is:
xmlToParse = Buffer.from(xml, 'binary').toString('utf8')
in HttpHandler.parseXML().Ideally, once UTF8 encoded, only a Buffer object should be used, but that requires more extensive changes. The switch to using "Content-Length" rather than chunked encoding makes the fix easier (saves 19 bytes on the wire, but breaks the CIRAChannel test - fix below).
The text was updated successfully, but these errors were encountered: