Closed datafatmunger closed 10 years ago
Could you write a failing test for this issue? Cheers
I've tried looking into this issue by writing a failing test but I can't see the issue. We use strings not buffers as STOMP is a Text Orientated Messaging Protocol. Can you explain why you want to use buffers?
Hey Ben,
I need to use buffers because we often see messages like "één fiets" in Dutch (we are a Dutch startup). Therefore it is unsafe to assume 1 character = 8 bytes, and setting the content length of the body of a frame based on the string length often truncates the body. If you put the string in a buffer, and get the length of the buffer for the it will be the actual length of the body. I'm fairly confident in my fork, we've been using it in production for 6 months now.
Thanks for that. I'll see if I can get some tests written and take it from there. Time to whip out the unicode snowman ;)
/to @bgraves I'm familiar with this problem in other languages, but I spent 10 minutes trying to create strings or buffers where the character length and byte length were different, and failed do to my lack of experience in node.js encodings. I can prepare a test for this against your changes if you provide some code snippets showing how to make buffers that trigger this problem. Thanks.
This is now fixed in 0.5.0
If a message contains utf8 StompFrameEmitter.prototype.parseBody function and the StompFrame.prototype.send function don't work properly. I managed to patch it (will fork) in a somewhat inelegant manor: