Oh, never mind.

It seems this optimisation already works (both in 1.x and 2.x), but
only if we don't fallback to mochiweb json encoder which is the case
when we cannot have NIF module loaded (by various reasons) - that's
your case.
Probably, the better fix would be to add the utf8 option here:
https://github.com/apache/couchdb/blob/1.x.x/src/ejson/ejson.erl#L77

and apply the patch for the bug you recently found of course:
https://github.com/mochi/mochiweb/commit/57a890aa2886d703c643bf05c99d3cf0e1ab28a0

For 2.0 there is no action need as we always use jiffy there with
force_utf8 flag:
https://github.com/apache/couchdb-couch/blob/master/src/couch_util.erl#L393

--
,,,^..^,,,


On Sun, Mar 20, 2016 at 6:38 PM, Alexander Shorin <kxe...@gmail.com> wrote:
> Hi.
>
> I got interested by this change, but suddenly only now get a change to
> test this and I'm actually confused:
>
> $ curl -XPUT http://localhost:5984/db/somedoc -d '{"привет":
> "\u043c\u0438\u0440"}' -H 'Content-Type: application/json'
> {"ok":true,"id":"somedoc","rev":"1-d97dcb1c5d13649423ebe8c282544bce"}
> $ curl http://localhost:5984/db/somedoc
> {"_id":"somedoc","_rev":"1-d97dcb1c5d13649423ebe8c282544bce","привет":"мир"}
>
> What is your case when you get \uXXXX responses?
>
> --
> ,,,^..^,,,
>
>
> On Sat, Mar 19, 2016 at 6:20 PM, ermouth <ermo...@gmail.com> wrote:
>> CouchDB normally delivers non-latin chars in JSON encoded as \uXXXX
>> entities, that is in most cases meaningless overhead.
>>
>> Known roundtrip, lists that re-encode responses, is very slow for views and
>> not applicable to replication traffic at all.
>>
>> Good way is to rebuild CouchDB from sources, making these changes:
>>
>> 1. Replace mochijson2.erl with
>> https://github.com/mochi/mochiweb/blob/master/src/mochijson2.erl, that has
>> critical fix
>> 2. Change utf8=false to utf8=true at LOC #95
>> 3. Recompile CouchDB.
>>
>> Voila, now all json responces are utf-8.
>>
>> ermouth

Reply via email to