Skip to content

4 byte unicode seems to be counted as 2 bytes #600

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
1 of 2 tasks
freman opened this issue Jun 6, 2018 · 3 comments
Closed
1 of 2 tasks

4 byte unicode seems to be counted as 2 bytes #600

freman opened this issue Jun 6, 2018 · 3 comments
Labels
enhancement New feature or request

Comments

@freman
Copy link

freman commented Jun 6, 2018

You want to:

  • report a bug
  • request a feature

Current behaviour

var socket = io({ transports: ['polling'], forceBase64: true });
socket.emit('chat message', '🎉');

Counts the 🎉 as 2 bytes, but it's actually 4

which results in it sending 23:42["chat message","...."] over the wire

It should be sending25:42["chat message","...."] over the wire

Conversely when I send back 25:42["chat message","...."] the client disconnects

Steps to reproduce (if the current behaviour is a bug)

var socket = io({ transports: ['polling'], forceBase64: true });
socket.emit('chat message', '🎉');
socket.on('chat message', function (msg) {
    console.log(msg);
});

Expected behaviour

send and receive 🎉 over a polling connection

Setup

Other information (e.g. stacktraces, related issues, suggestions how to fix)

I'm using the googollee go-socket.io library in linux. You can put together an exact sample of what I have with (Assuming you have go installed)

go get github.com/googollee/go-socket.io
cd $GOPATH/src/github.com/googollee/go-socket.io/example
sed -i bak \
    -e 's/= io()/= io({ transports: ['polling'], forceBase64: true })/' \
    -e 's,/socket.io-1.3.7.js,//cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.dev.js,' assets/index.html
go run main.go

A chat will be started on localhost:5000 you can try sending unicode characters

@darrachequesne
Copy link
Member

Related: socketio/engine.io-parser#81 (comment)

I guess we'll have another breaking change then..

@darrachequesne darrachequesne added the enhancement New feature or request label Jun 4, 2020
@darrachequesne
Copy link
Member

@darrachequesne
Copy link
Member

Fixed in Engine.IO v4: https://socket.io/blog/engine-io-4-release/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants