Thanks Chris, the #printString was indeed a good idea :)

On Wed, Jul 24, 2013 at 1:38 PM, Chris Cunningham
<[email protected]>wrote:

> Doesn't just #printString do this?  It escapes single strings into doubles
> - should do what you want if it is definitely a string.
> -Chris
>
>
> On Wed, Jul 24, 2013 at 8:34 AM, Mariano Martinez Peck <
> [email protected]> wrote:
>
>> Hi guys. I am a bit lost here and maybe someone can give me a hand. I
>> have a string that may include a single quote inside. Say I have the
>> string 'Sell ''13' . This string actually has a SINGLE quote, so if you
>> print it in a file for example, you get 'Sell '13'. Of course, when you
>> inspect the string in Pharo, it has 2 single quotes: 'Sell '' 13'. ok?
>>
>> Now...what I need is (quite weird I know) is to build a closure as a
>> string and using the previous string as a literal of the closure.
>>
>> Imagine there is no single quote problem in my string, this would work
>> perfect:
>>
>> (Compiler evaluate: '[  ', ' Transcript show: ', 'Sell '
>> surroundedBySingleQuotes, ']') value.
>>
>> But, if instead of having 'Sell ', I have 'Sell '' 13', like this:
>>
>> (Compiler evaluate: '[  ', ' Transcript show: ', 'Sell '' 13'
>> surroundedBySingleQuotes, ']') value.
>>
>> I get a SyntaxError of a unmatched string:
>>
>> [   Transcript show: 'Sell ' 13Unmatched string quote -> ']
>>
>> So...what can I do?  I GUESS the solution is to scape that. If I try
>> adding 2 more single quotes, like this:
>>
>> (Compiler evaluate: '[  ', ' Transcript show: ', 'Sell '''' 13'
>> surroundedBySingleQuotes, ']') value.
>>
>> it seems to work.  If this is correct, is there an easy way (a method?)
>> to scape my string automatically so that it works?
>>
>> Thanks in advance,
>>
>> --
>> Mariano
>> http://marianopeck.wordpress.com
>>
>
>


-- 
Mariano
http://marianopeck.wordpress.com

Reply via email to