Code Monkey home page Code Monkey logo

Comments (7)

nkzawa avatar nkzawa commented on May 18, 2024

報告ありがとうございます。
マルチバイト文字列は完全に対応してるつもりなのですが、再現条件等わかったらおしえてもらえると助かります!

from socket.io-client-java.

maimuzo avatar maimuzo commented on May 18, 2024

検証用ファイルを用意してみました。
https://github.com/maimuzo/socket.io-client.java/tree/master/multibyte_test
上記のadb_log.txtを見てもらうのがわかりやすいと思います。

症状としては、
・ASCIIは化けない
・Androidの文字リテラルをサーバに送ると化ける
・サーバの文字リテラルをAndroidに送ると化ける
・Android->サーバ->Androidは化けない
のようです。

ただ、やはり再現性がわからないですが、正常に受信できる時もあります。(これは検証用のソースではなく、別アプリ側で確認しています)
マルチバイト文字を含むデータを何度か受信すると、ある時を境に正常に受信できて、またある時を境にできなくなります。
ソースを見てないですが、チャンクの関係でしょうか?

検証ファイルは用意してないですが、ブラウザ→サーバと、サーバ→ブラウザは大丈夫のようです。

from socket.io-client-java.

nkzawa avatar nkzawa commented on May 18, 2024

詳細な報告ありがとうございます!!
一点気になったのですが、古いバージョンを使っているようなので、最新(0.2.0)にアップデートしてみてもらえますか?
サーバ側のsocket.ioのバージョンも知りたいです。
socket.ioの1.0.xと1.1.0で、若干のプロトコル変更があったためその影響の可能性がありそうです。

from socket.io-client-java.

maimuzo avatar maimuzo commented on May 18, 2024

下記を参考に文字コード推定の検証してみました。
http://qiita.com/shoma2da/items/c77ec534dd36873d73c9

またファイルを更新しました。
https://github.com/maimuzo/socket.io-client.java/tree/master/multibyte_test
ここのcodec_check_node_log.txtがnode側のログですが、
node.js内の文字列リテラルがasciiと判定されていて、送られてきた文字列が(化けてますが)utf-8と判定されています。

もしかすると、node.jsの実行時にマルチバイトをasciiとして評価して実行するようなオプションがあるのかもしれないですが(調べても見つけられませんでした)、もしそんなオプションがなく、node.js内では文字列リテラルはUTF-8扱いされるのであれば、multibyteCharactorsがascii扱いされる理由がよくわからないですね。

一方Androidから受け取った文字がUTF-8なのは想定内なのですが、何故か文字化けしてしまっています。

自分はnode.jsに慣れてないので、このあたりがよくわかってないです。

dump ascii: abcABC123!"#
dump ascii2: abcABC123!#
dump multibyteCharactors: あいうえお
dump multibyteCharactors2: あいうえお
dump data: �����
detect ascii:
{ encoding: 'ascii', confidence: 1 }
detect ascii2:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors2:
{ encoding: 'ascii', confidence: 1 }
detect data:
{ encoding: 'utf-8', confidence: 0.9690625 }

from socket.io-client-java.

maimuzo avatar maimuzo commented on May 18, 2024

「node.jsの実行時にマルチバイトをasciiとして評価して実行するようなオプション」が意味不明だと思いますが、
ruby -K[kcode]
のようなものが、node.jsにもあるのかなと想定していました。

from socket.io-client-java.

maimuzo avatar maimuzo commented on May 18, 2024

すいません。
compile 'com.github.nkzawa:socket.io-client:0.2.0'
これで直りました。orz
こんな初歩的な話だったとは…お手数掛けました。

ちなみに、
received ping, test_type: android json multibyte charactor, data: {"multibyteCharactors":"あいうえお"}
received ping, JSON.parse(data): [object Object]
dump ascii: abcABC123!"#
dump ascii2: abcABC123!#
dump multibyteCharactors: あいうえお
dump multibyteCharactors2: あいうえお
dump data: {"multibyteCharactors":"あいうえお"}
detect ascii:
{ encoding: 'ascii', confidence: 1 }
detect ascii2:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors:
{ encoding: 'ascii', confidence: 1 }
detect multibyteCharactors2:
{ encoding: 'ascii', confidence: 1 }
detect data:
{ encoding: 'ascii', confidence: 1 }
となって、やっぱりマルチバイト文字はasciiと推定されてしまいますね。
これは評価器側の問題な気もしますが。

お手数掛けました。ありがとうございました。

from socket.io-client-java.

maimuzo avatar maimuzo commented on May 18, 2024

一応履歴として。
$ node -v
v0.10.25
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ ├── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]

from socket.io-client-java.

Related Issues (20)

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.