Giter Club home page Giter Club logo

Comments (7)

endquote avatar endquote commented on September 16, 2024

Hm. I've been doing some stuff with emoji in JS and have learned that JS can kind of suck with Unicode in general. ES6 is better, but the day for that rewrite is not yet here.

The OSC module being used is the latest, so that's not a fix.
https://github.com/TheAlphaNerd/node-osc

Do you want to do a sample app that sends what you need as an OSC blob, and we can try to tweak _handleOsc to deal with it?
https://github.com/stimulant/ampm/blob/master/model/network.js#L163

It would be easiest for me to troubleshoot with a binary app that has a button that sends a message that repros the problem. And another button that sends it as a blob instead of a string?

In the meantime I committed a change that should at least keep it from crashing. It's on npm too.

from ampm.

LRitesh avatar LRitesh commented on September 16, 2024

Ah, I didn't realize that _handleOsc is where the JSON is parsed before being sent to _logEvent.

FWIW, if I send something like "Writing Chicago\u2019s Story" as the event's Category value (with the ampm Cinder sample), it shows up inside _handleOsc as "Writing Chicago\u0012s Story". And JSON.parse() throws an exception [SyntaxError: Unexpected token �]. So this is where it fails to parse the string. Not sure if there's a way to have JSON.parse handle UTF-16 data, but might be worth looking into that.

from ampm.

endquote avatar endquote commented on September 16, 2024

Maybe we need to do some escaping in the ampm client library?
http://stackoverflow.com/a/11654338/468472

Or escape it in _handleOsc before passing it to JSON.parse.

from ampm.

richardeakin avatar richardeakin commented on September 16, 2024

@endquote for reproducing, I can on Mac with the provided cinder sample by changing this line to (not sure if this will work on windows as you can't directly write utf16 in strings until vc140):

string action = "Writing Chicago\u2019s Story";
AMPMClient::get()->sendEvent( "category", action, "label", 10 );

@LRitesh hm, so it shows up as just one char off?

I've only briefly researched the js side of things, but this gist makes me think that JSON.parse can handle UTF-16 just fine (as does cinder's jsoncpp), and the problem is likely to be in node-osc's parsing, which expects ASCII chars. Here's a [vvvv forum](https://vvvv.org/forum/encode-problem-with-strings-and-umlauts-via-udposcdecoder post) with similar issues. I believe they recommend sending the data as a blob as well, base64 encoding it first. OSC can be a pain sometimes, huh.

I don't think we need to double-escape the utf-16 chars, we're able to read down the json OK from our CMS as-is, load it in the app and display it. It's just once it gets sent over OSC that things go awry.

from ampm.

LRitesh avatar LRitesh commented on September 16, 2024

@endquote I tried decodeURIComponent(message[1]) before sending it to _logEvent but running into the same issue still.

@richardeakin I was looking at that gist as well. It does sound like the issue might be in node-osc's parsing, because it's replacing \u2019 to \u0012 before JSON parse is even used on the string.

from ampm.

endquote avatar endquote commented on September 16, 2024

How do you get the Mac Cinder sample to build on Yosemite? I don't think environment variables are really a thing anymore. Do we need to update the readme?
https://github.com/stimulant/ampm/blob/master/samples/Cinder/README.md

from ampm.

richardeakin avatar richardeakin commented on September 16, 2024

I haven't added anything related to app transport myself, but I've only done brief testing on Mac while our main target is win10.

from ampm.

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.