[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] String:escapeSpaces



Also it's platform dependent. Windows doesn't use backslash to escape
spaces -- spaces in Windows paths must be handled by wrapping the path
in double quote marks.

There is already an escapeChar method, but it doesn't allow you to
choose the escape character (a limitation that would be easy to fix).

hjh

On 11/29/06, Stefan Kersten <sk@xxxxxxxxxx> wrote:
Scott Wilson wrote:
> Any reason not to add this:
>
> + String {
> escapeSpaces {
> var result;
> this.do({ arg char;
> if(char.isSpace,{result = result ++ $\\ ++ " "},{result = result ++ char})
> });
> ^result
> }
> }
>
> and then stick it in in the various String methods which deal with paths?

why not factor isSpace into a predicate that is passed to the method
along with the escape character? would make it more useful in other
contexts, and escapeSpaces could just be ^this.escapeChars(_.isSpace, $\\);

<sk>

_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev



--
James Harkins /// dewdrop world
jamshark70@xxxxxxxxxxxxxxxxx
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman