From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 882B9BC57 for ; Tue, 8 Jun 2010 20:52:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcBAC8uDkzVhjEYkGdsb2JhbACeVgEBAQEJCQwHEQMfv2GFFgSDZw X-IronPort-AV: E=Sophos;i="4.53,385,1272837600"; d="scan'208";a="52694360" Received: from ihsmtp02voda.lis.interhost.com (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Jun 2010 20:52:45 +0200 Received: from [192.168.1.64] ([95.136.106.136]) by ihsmtp02cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 8 Jun 2010 19:52:44 +0100 Message-ID: <4C0E9177.4080802@inescporto.pt> Date: Tue, 08 Jun 2010 19:52:39 +0100 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Markus Mottl Cc: caml-list Subject: Re: [Caml-list] Escaped string in sexplib References: <4C0E6561.20207@inescporto.pt> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 08 Jun 2010 18:52:44.0399 (UTC) FILETIME=[C7A2C7F0:01CB073B] 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 markus:01 unescape:98 unescape:98 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). Can anyone suggest a solution or correction? TIA, Hugo F. > Regards, > Markus >