Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B539BE524 for ; Wed, 30 Jan 2013 08:18:48 +0000 (UTC) Received: (qmail 36381 invoked by uid 500); 30 Jan 2013 08:18:47 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 36135 invoked by uid 500); 30 Jan 2013 08:18:46 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 36120 invoked by uid 99); 30 Jan 2013 08:18:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jan 2013 08:18:46 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.216.175 as permitted sender) Received: from [209.85.216.175] (HELO mail-qc0-f175.google.com) (209.85.216.175) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jan 2013 08:18:41 +0000 Received: by mail-qc0-f175.google.com with SMTP id j3so606918qcs.20 for ; Wed, 30 Jan 2013 00:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=qpblUGzSpAV128CBB1BkrhgbMLZ2MJxX7I9GTdVzhcU=; b=noGCbDRHVv6ozK0enXdIYaEDHBbm8rxvtobeijb1W+482ESU94UYEJaheLWppJZXBM SanPXp9WrBR/KvCc4YYhUkjpcW3nRFLcQWdIgWDiuD2v34h8ihtyFT5Vn8xgG7l8QTs3 /NdeXpc1GmL+za00BzP4oBJH0OJNjsygRMjfd+cs+k73UaF0Mb+/8pKh+FiGOzfOO0zS y9DXoQArJXHruY2zTZWYCBNud51DmS86QpHyPUiAb3YwRkdaZr5KTDD/sxXqJbn+yQ26 l0g27uk4p1tAPDhHotoNlAvUT0rQZXboQQIAs/bDwsTAd/VG4GiNnMWz3KNF0VVZQ48Z NspQ== X-Received: by 10.49.71.204 with SMTP id x12mr4547330qeu.47.1359533900281; Wed, 30 Jan 2013 00:18:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.49.47.112 with HTTP; Wed, 30 Jan 2013 00:17:40 -0800 (PST) In-Reply-To: References: From: Paul Davis Date: Wed, 30 Jan 2013 02:17:40 -0600 Message-ID: Subject: Re: lexical error: invalid character inside string To: "user@couchdb.apache.org" Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org As you specifically showed in your original email sending the two bytes 0x5C72 (\r) from curl works correctly. Your R environment appears to be doing various types of unescaping before sending the data along to CouchDB which is what's causing you issues. >From what you've shown the three characters 0x5C5C72 (\\r) works while two bytes 0x5C72 (\r) and four bytes 0x5C5C5C72 (\\\r) do not work. Most likely what is happening here is that R is unescaping your input. Thus the three byte example 0x5C65C72 (\\r) is unescaped internally to the two byte 0x5C72 (\r) sequence. Where as 0x5C72 (\r) and 0x5C5C5C72 (\\\r) are unescaped to 0x0D (carriage return) and 0x5C0D (\ and a carriage return) respectively. Basically, you need to work on your R un|escaping semantics to make sure you're sending the right byte sequences to CouchDB. The easiest way to accomplish this is to use a proper JSON library instead of building JSON objects by hand. HTH On Wed, Jan 30, 2013 at 1:47 AM, Thomas Bock wrote: > > Thank you for the answer! > >> > curl -X PUT --data '{"a": "\r"}' --header "Content-Type: application/= json" >> http://localhost:5984/r_test/ab7a >> >> I think JSON does not allow literal returns/newlines (or other >> control characters) inside strings; they have to be backslash- > > But the curl line works; and in futon I also can type in a simple \r > >> escaped. It=92s hard to follow exactly what=92s going on through all the >> levels of quoting and unquoting that happen in the shell and in the >> Erlang output, but I think you haven=92t escaped that \r enough =97 it >> probably needs to be "\\\r". > > This ("\\\r") don't work; "\\r" works. Since \r is the end sign > of a gauge (and it don't accept any other) for a measurement value query > I need a reliable way. > >> >> FYI, as a side note, I=92ve found the =91httpie=92[1] utility a lifesave= r >> when talking to CouchDB (and other REST/JSON APIs) from the command >> line. It=92s like a souped-up curl with a much clearer syntax for >> setting query parameters, and the ability to easily specify a JSON >> body. For example, I can run your same command as: >> >> http PUT :5984/r_test/ab7a a=3D'\r=92 >> >> =97Jens >> >> [1]: https://github.com/jkbr/httpie