Automatically convert all input to utf8 before sending to Stripe #27

boucher opened this Issue Jan 4, 2013 · 3 comments


None yet

2 participants

boucher commented Jan 4, 2013

We have a utf8 helper, but we only use it on URLs, not on any of the parameters. One possible solution could be to add a check in _encodeObjects of ApiRequestor.

ebroder commented Feb 20, 2013

I'm pretty suspicious of this. In fact, I'm suspicious of us using utf8_encode at all.

utf8_encode converts latin-1 strings to UTF-8, which isn't an idempotent transformation. That means that if somebody passes in a string that's already UTF-8 encoded, we'll mangle it:

php> var_dump(unpack('C*', utf8_encode("\xc3\xa9")))
array(4) {

I think ideally I'd argue for dropping the utf8 helper entirely and making it the developers' responsibility to pass us UTF-8, though I think in practice that's somewhat tricky. Thoughts?

boucher commented Feb 20, 2013

You can check for something that thinks it is encoded in UTF 8 already though, no?

ebroder commented Feb 20, 2013

Hmm, yeah, plausible. I'll try to sketch up something

@ebroder ebroder closed this in 292ab8b Feb 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment