Skip to content

Conversation

wxhuang
Copy link
Contributor

@wxhuang wxhuang commented Jun 19, 2015

Buffer强转为string时,非ascii字符可能会变乱码,此时不应强转string.

@JacksonTian
Copy link
Member

有没有测试用例。什么情况下会出现。

@JacksonTian
Copy link
Member

凭我的直觉,乱码问题不应该在这个地方解决。

@wxhuang
Copy link
Contributor Author

wxhuang commented Jun 19, 2015

res.reply(new Buffer('f7f7f7', 'hex'));

返回字符串经过base64解码后变成:

<Buffer ef bf bd ef bf bd ef bf bd>

参考资料:
http://blog.flanker017.me/%E8%AF%91%E5%BD%93efbfbd%E6%9D%A5%E6%95%B2%E9%97%A8-%E5%AF%B9java%E4%B8%AD%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%B8%8Ebyte%E6%95%B0%E7%BB%84%E8%BD%AC%E6%8D%A2%E5%AF%B9%E4%B8%80%E4%B8%AA%E8%A7%82%E5%AF%9F/

@JacksonTian
Copy link
Member

@wxhuang
Copy link
Contributor Author

wxhuang commented Jun 19, 2015

蓝牙设备通过微信和服务器通信,有时需要处理一些二进制包这样子.

@JacksonTian
Copy link
Member

确认二进制包都收完了么。

@wxhuang
Copy link
Contributor Author

wxhuang commented Jun 19, 2015

不是很清楚你说的哪一步.
两端处理二进制包的流程是:
1.设备发送二进制包到微信;
2.微信对二进制包base64编码并发送给服务器;
3.服务器收到base64数据;
4.服务器回复二进制包;
5.node-wechat模块对二进制包base64编码并发送给微信;
6.微信对base64数据解码并发往设备;
7.设备收到二进制包.
第7步的数据是收完了的.

@wxhuang
Copy link
Contributor Author

wxhuang commented Jun 24, 2015

请问还需要了解什么东西?

JacksonTian added a commit that referenced this pull request Jun 24, 2015
处理回复设备消息为二进制数据时乱码的问题.
@JacksonTian JacksonTian merged commit bac6d4a into node-webot:master Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants