GithubHelp home page GithubHelp logo

UTF-8 encoding woes about singer-python HOT 4 OPEN

singer-io avatar singer-io commented on July 22, 2024
UTF-8 encoding woes

from singer-python.

Comments (4)

KAllan357 avatar KAllan357 commented on July 22, 2024

Hi @martint17r - thanks for the issue.

I'm curious why this hasn't been a problem for any other consumers of this library. I am a little concerned about the downstream effects of such a change. I suspect there is no greater issue because our target-stitch library uses the corresponding parse_message function which is able to consume the ASCII output using json's loads.

I'm not sure if its relevant in this case, but in the past - when PYTHONIOENCODING was not enough - I've had to set the LANG environment variable described in this issue docker-library/python#13.

In any case, I'd be happy to merge a PR for this change if you make the default function work as it has worked but provide a flag to use your described behavior.

from singer-python.

martint17r avatar martint17r commented on July 22, 2024

I believe the reason why this has not popped up anywhere else is that this is not a problem within python, i.e. the escaped unicode notation is a Python specific encoding, see 7.2 Python specific encodings, which it tolerates.

I ran into that problem, because I am trying to implement a target in Go.

According to RFC 8259 Ch. 8.1 JSON must be encoded in UTF-8, even RFC 7493 Ch. 2.1 agrees on that.

Would you accept a second pull request to PROPOSALS.md to enhance the SPEC accordingly, i.e. define a MUST-HAVE UTF-8 encoding for all data? Something along the lines of:
"A Tap outputs structured messages to stdout in JSON format, one message per line, UTF-8 encoded".

I agree that this mandates a major version change in semver notation.

from singer-python.

KAllan357 avatar KAllan357 commented on July 22, 2024

This makes sense and both parts sound like a good change. I've done some preliminary testing and Python seems happy to decode both the escaped and not-escaped versions of the string.

Making it an option seems unnecessary - if you could make a PR to add the flag and we can do a major bump to 6.0.0. Adding to the Singer Spec sounds good too. Thanks for this!

(note: this SO question helped me understand the issue and there seems to be less confusion in Python 3 than 2 - the dumps function no longer returns a string OR unicode object when this flag is present)

from singer-python.

ashutoshvarma avatar ashutoshvarma commented on July 22, 2024

Any update on this? For now I am using ensure_ascii=False locally.

from singer-python.

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.