Hi Andy,

On Mon, Aug 12, 2013 at 12:17 AM, Andy Fingerhut
<andy.finger...@gmail.com> wrote:
> Clojure's clojure.string/trim uses Java's String/trim, but
> clojure.string/triml and trimr use Java's Character/isWhitespace to
> determine which characters are white space to remove.  CLJ-935 has a
> suggested patch to make them all use Character/isWhitespace:
>
>     http://dev.clojure.org/jira/browse/CLJ-935
>
> Character/isWhitespace doesn't consider Unicode code point 0x00A0 a
> whitespace character, either, though.  Java's Character/isSpaceChar does,
> but neither of those Java methods recognize a set of whitespace characters
> that is a superset of the other.  Fun, eh?

Thanks for the pointer to the ticket.

Since I can't seem to comment on the ticket there, wouldn't it make
sense to make trim blow away anything that isWhitespace or isSpaceChar
returns true for? I get the problem with the host platform's trim
method not agreeing, but semantically trim is supposed to trim
whitespace from the beginning and end of a string, and either of those
two methods are talking about whitespace (albeit in subtly different
ways for whatever reason).

> I'd recommend writing your own trim that gets rid of exactly what you want.
> Start by copying from the existing triml or the version of trim in the patch
> for CLJ-935 and tailoring the condition for whitespace characters to your
> heart's desire.

I got around the problem by taking a more 'declarative' approach and
removing everything in the string that wasn't a digit. That's probably
more forward compatible anyway but of course could lead to false
positives in the code elsewhere.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to