[Openmcl-devel] Arbitrary characters in strings

Gary Byers gb at clozure.com
Fri Mar 26 20:19:13 UTC 2010


I could imagine that something mostly like the standard #\" reader
macro could be useful.  One way that that could be defined is to say
that double-escape characters are used to delimit character names (and
double-escape characters have to be single-escaped to be treated 
literally.)

If that reader macro was defined on #" (which isn't necessarily a good
choice, since that's attractive enough that application code may be
tempted to use it, even though it's not explicitly reserved for application
use), then one would be able to say:

#"My |Latin_Small_Letter_A_With_Macron| string"

or

#"My |u+0101| string"

and would have to say:

#"Vertical bars look like this: \|"

The cl-interpol package that Stelian Ionescu just mentioned seems like
this idea on steroids.

If the original question is "how do I embed a character in a string
constant defined by #\" ?", the answer is "type it[1], since CL doesn't
define much in the way of character-escaping behavior for the standard
#\" macro."

[1] As always, management is not responsible for damage that may result
from trying to type cuneiform characters.


On Fri, 26 Mar 2010, Ron Garret wrote:

> ? #.(format nil "My ~A string" #\Latin_Small_Letter_A_With_Macron)
> "My ā string"
>
> And if you need to
>
> On Mar 26, 2010, at 11:17 AM, Daniel Weinreb wrote:
>
>> CCL supports, e.g., #\u+0101 and #\Latin_Small_Letter_A_With_Macron
>> as character objects, in the reader.  What if I'm putting a literal string
>> into my program and I want it to contain such a character, not by
>> using the character itself but by naming it, as above?
>> 
>> Thanks.
>> 
>> -- Dan
>> 
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel


More information about the Openmcl-devel mailing list