From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id AA0A9BC57 for ; Tue, 8 Jun 2010 21:42:55 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoIBAOc5DkzRVaE0mGdsb2JhbACSLowMCBUBAQEBAQgJDAcRIq8VggKFNC6ITwEBAwWFEQSDQiU X-IronPort-AV: E=Sophos;i="4.53,385,1272837600"; d="scan'208";a="51996389" Received: from mail-fx0-f52.google.com ([209.85.161.52]) by mail3-smtp-sop.national.inria.fr with ESMTP; 08 Jun 2010 21:42:55 +0200 Received: by fxm19 with SMTP id 19so2886729fxm.39 for ; Tue, 08 Jun 2010 12:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:openpgp:content-type:content-transfer-encoding; bh=PdadwiBLZXx+kXjbbugCbYRu8PWzlS6iupSJHgoR/6Y=; b=ftng2zG1V3yf0ZhcbCbI8z0r6edyrrFYGCHeX0lD9XRHrZ42AEFcj8uIWYl4XHQaoW a27iGXF5ykMpuiunsKUyrGu/ka+hUYzplBDwQxq+/L5BVj7l6tmTBO0CJfy/QEnzKRNZ 5TRQjQu7IHr00avG0ti/6kBJZeX/yO3sVEMt0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:openpgp:content-type :content-transfer-encoding; b=mLAH6g79+bS4LvU9JdcPUrrT22w2ReuoRXcsXQUP1mQna4qSHcxOPx5hT7hlfwa2R1 6SKJt7etA1aP9noAPe9EHwh9YEZ3aimpj3pOQ3sJJn2hj4i1hoik8vo5LUl2ik6ETwPS XYnwwMU8oWSKMnjEfjY95v3EUSJAZbCA72FcQ= Received: by 10.223.50.193 with SMTP id a1mr5069124fag.34.1276026174261; Tue, 08 Jun 2010 12:42:54 -0700 (PDT) Received: from debian ([79.114.32.154]) by mx.google.com with ESMTPS id u12sm26934373fah.4.2010.06.08.12.42.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Jun 2010 12:42:53 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by debian (Postfix) with ESMTP id 6EDB72F419 for ; Tue, 8 Jun 2010 22:42:52 +0300 (EEST) Message-ID: <4C0E9D3C.3070104@gmail.com> Date: Tue, 08 Jun 2010 22:42:52 +0300 From: =?ISO-8859-1?Q?T=F6r=F6k_Edwin?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Escaped string in sexplib References: <4C0E6561.20207@inescporto.pt> <4C0E9177.4080802@inescporto.pt> In-Reply-To: <4C0E9177.4080802@inescporto.pt> X-Enigmail-Version: 1.0.1 OpenPGP: id=5379965D Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; markus:01 mottl:01 pointers:01 sexp:01 sexp:01 escapes:01 ocaml:01 ocaml:01 camlp:01 camlp:01 syntax:01 struct:01 ocamlc:01 ocamlfind:01 ocamlc:01 On 06/08/2010 09:52 PM, Hugo Ferreira wrote: > Hello, > > Markus Mottl wrote: >> On Tue, Jun 8, 2010 at 11:44, Hugo Ferreira wrote: >>> I am trying to us the Sexplib library to process data. >>> However I am having some trouble with strings. >>> Specifically I need to save and restore strings to a file >>> so that the escaping done during saving is "undone" >>> when data is read back in. >>> >>> How can I do this? Appreciate any pointers. >> >> The I/O and parsing routines in the S-expression library should take >> care of escaped strings just fine. > > My apologies but I did not explain myself correctly. The problem here is > that I am trying to automate the conversion to string of the data > structure read from the s-expressions. I have the following: > > let string_of_experiment_data data = > let data = sexp_of_experiment_data data in > Sexplib.Sexp.to_string_hum data > > The problem here is that the "to_string_hum" escapes certain characters, > but I need to have the strings "not escaped". So my question is: is > their any way I can tell sexplib to output a string but not escape > it? Otherwise I will have to hand encode this stuff 8-( > >> Btw., the escaping conventions are >> absolutely identical to the ones used by OCaml. >> > > I am aware of this as it is indicated in your documentation and > the ocaml tutorial site. I also searched for a means to "unescape" > the result from "to_string_hum", which would also work. However > I cannot find a String.unescape. This issue has already been pointed > out. A possible solution would be to use the old. > > Token.eval_string > > and I cannot seem to use the equivalent of the new camlp4. The > equivalent: > > open Camlp4.PreCast > open Syntax > let eval_string s = Camlp4.Struct.Token.Eval.string ~strict:() s > > does not compile (Error: Unbound module Camlp4.PreCast). It compiles for me if I add -I +camlp4: ocamlc -I +camlp4 -c x.ml or: ocamlfind ocamlc -package camlp4.lib -c x.ml It also links if you add -linkpkg. Best regards, --Edwin