Zend Framework: Zend_Filter_StripSpaces Component Proposal
| Proposed Component Name | Zend_Filter_StripSpaces |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_StripSpaces |
| Proposers | Thomas Weidner |
| Revision | 1.0 - 04 Oktober 2009 (wiki revision: 10) |
Table of Contents
1. Overview
Zend_Filter_StripSpaces will strip all spaces out of a string. You can specify if you want to strip out all spaces or just the unnecessary ones, means multiple spaces behind one another.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will correctly strip out all repeated spaces, as they are insignificat in some context (e.g. html)
- This component will correctly strip out all spaces, when specified
- This component will also handle Unicode White Spaces
- This component will not remove any other character
4. Dependencies on Other Framework Components
- Zend_Filter_Interface
- Zend_Filter_Exception
5. Theory of Operation
Based on the specified options, this filter will strip all, more than one and/or also unicode white spaces.
6. Milestones / Tasks
- Milestone 1: [DONE] Proposal finished
- Milestone 2: Proposal accepted
- Milestone 3: Working implementation
- Milestone 4: Unit tests
- Milestone 5: Documentation
- Milestone 6: Moved to core
7. Class Index
- Zend_Filter_StripSpaces
8. Use Cases
| UC-01 |
|---|
Default, stripping multiple whitespaces (textual, unicode and html)
| UC-02 |
|---|
Stripping only multiple textual whitespaces
| UC-03 |
|---|
Stripping all whitespaces
| UC-04 |
|---|
Stripping multiple types of whitespaces
| UC-05 |
|---|
Stripping more than 3 whitespaces
9. Class Skeletons
Labels:
None
11 Comments
comments.show.hideMar 03, 2008
Martin Hujer
Hi,
this filter maybe should also strip tabs [\t]
Regards
Martin H.
Apr 18, 2009
Thomas Weidner
Karol, please tell me if you want to do any further progress with this proposal.
Otherwise I will take it over, change it to conform, get it approved and integrated.
Greetings
Thomas Weidner
Jul 28, 2010
Dolf Schimmel (Freeaqingme)
Why can't it filter out other characters on demand of the developer? If I want to filter out all occurrences of 'A' or 'a', this component should be able to. Imho.
Jul 30, 2010
Thomas Weidner
This filter is intended to work only on spaces. You should note that unicode defines other whitespace characters which most people are not aware of.
When you want to have a filter which strips out special characters then I would add a Zend_Filter_StripCharacters... Zend_Filter_StripSpaces would then be an extension of StripCharacters.
I would do this based on this proposal when it's really wished.
Jul 29, 2010
Shaun Farrell
If you have sentences and you used the default stripping what would the use case be for after a "."
Example
"This is a sentence. This is another sentence."
Would it remove the double space after the sentence or leave that in?
Jul 30, 2010
Thomas Weidner
In your example there is no double whitespace after the point.
But when there would be a multiple-whitespace it would be stripped.
It would change TEXT-POINT-SPACE-SPACE-TEXT and return TEXT-POINT-SPACE-TEXT
Jul 30, 2010
Marc Bennewitz (private)
For me it sounds like a html minimizer. This should be discussed with Nick Daugherty's Zend_Filter_Minify_Html.
Jul 30, 2010
Thomas Weidner
No... this proposal is not intended to work on HTML or any other structured content.
It has no knowledge of any structure.
Minify_Html would not work on a plain string text or on a textfile.
Aug 03, 2010
Pádraic Brady
The CR Team advises that this proposal may be approved with the condition that the proposer clarify the precise range of characters that will be stripped.
Aug 03, 2010
Thomas Weidner
As written and proposed this component can strip all sorts of spaces. This would include:
Each of them can be switched on/off separatly. This component would also recognise the HTML variant and strip it. This can also be switched off per option.
Example:
Non-breaking Space = U+00A0 => HTML Variant = & nbsp;
For each of the above spaces a HTML variant exists.
Aug 04, 2010
Pádraic Brady
Thanks for the clarification Thomas!