Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #709 (closed enhancement: fixed)

Opened 16 years ago

Last modified 16 years ago

How about stripPattern

Reported by: yidabu Assigned to: kris
Priority: normal Milestone: 0.99.4
Component: Core Functionality Version: 0.99.2 Don
Keywords: tango.text.Util Cc:

Description (Last modified by yidabu)

seems tango.text.Util lacks a pattern version of trim or strip.

e.g. \u3000 is a SBC case space, but how to trim it from a UTF-8 source ?

toUtf32(source), strip(source, '\u3000'), then toUtf8(source) ?, is it a little tedious ?

add a stripPattern and trimPattern to tango.text.Util will usefull.

BTW, tango.text.Util added stripl and stripr now, why not add striml and strimr too like Phobos does ?

 yidabu: How to strip a SBC case, e.g. stripr!(char)("\u3000", '\u3000')

 DanielKeep: You'd have to use a Utf-32 string, I think

 DanielKeep: That second parameter really should be a dchar...

 yidabu: but the source is UTF-8

 yidabu: toUtf32, then stripr, then to utf8?

 DanielKeep: That, or write your own stripr

 Kris: in general, character-oriented text manipulation in Tango is expected to be performed in utf16/32.  Pattern-oriented manipulation is handled in all of utf8/16/32

 Kris: for example, all the Unicode character classification expects dchar only

 yidabu: thx! just toUtf32, stripr, then toUtf8 

 DanielKeep: You can probably do it faster using stripPattern

 DanielKeep: Which... doesn't appear to be in tango.text.Util

 yidabu: DanieKeep,  you written it ?

 DanielKeep: No; it looks like strip doesn't have a pattern version

 DanielKeep: You might want to make a ticket about it

 DanielKeep: Specifically mention that you wanted to strip high Unicode characters as well

Change History

10/29/07 06:04:59 changed by yidabu

  • description changed.

11/02/07 21:35:39 changed by kris

  • status changed from new to assigned.
  • milestone changed from 0.99.3 to 0.99.4.

12/02/07 19:49:02 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [2953]) tango.text.Util now has triml() and trimr() functions, along with chopl() and chopr() functions.

Fixes #709, with thanks to Yidabu