Adding as well as removing spaces is not desired. The string must remain unchanged other than it having newlines inserted, so
"1 2 3 4" converted to a col width of 1 would become exactly the same as
"1\n \n2\n \n3\n \n4\n"
Does this answer your question?
Arne Goedeke wrote:
I am still not quite sure right now what kind of behaviour you would like to have. Please tell me if I got it right: You want no skipping of spaces _but_ linebreaks between words? So adding spaces is ok but skipping is bad?
I am asking because your initial example was different (fixed field size much smaller than words, etc).
arne
On Tue, 5 Feb 2008, C. Schalkwijk wrote:
I do not know anything about the text or exact contents. All I know is that if there is more than one space inserted, it should stay that way, it's done intentionally. It would be better to assume that the spaces are intended than apply any 'correction' when using sprintf.
What if I _want_ my text to indent? Now it's not possible (not that I would want this at the moment), because sprintf assumes my text should not be indented (I want my code to think for me, only when requested). Sprintf should be a 'dumb' function and just apply the format I ask for, nothing more.
I could write my own function, but I still think it's faulty behaviour that sprintf changes my text this way. Again, it should not do that. I even think this is very _bad_ :)
Greets,
Coen
Martin Bähr wrote:
On Tue, Feb 05, 2008 at 01:24:49PM +0100, C. Schalkwijk wrote:
In my opinion, removing characters from a string (when not
requested) is > faulty behaviour and should not occur. 'possibly skipping or adding > spaces' is not desired.
but word wrapping can not be handled correctly in any other way.
if you want to set a text in a multiline block then any space that would end up at the beginning od a line must be removed because the line must start with text. otherwise the line would be indented.
therefore it is not possible to implement this correctly without removing spaces where linebreaks are introduced.
in what context do you want to format your text?
you may want to write your own function to wrap the text.
greetings, martin.
Deze e-mail en de inhoud is vertrouwelijk en uitsluitend bestemd voor de geadresseerde(n). Indien u niet de geadresseerde bent van deze e-mail verzoeken wij u dit direct door te geven aan de verzender door middel van een reply e-mail en de ontvangen e-mail uit uw systemen te verwijderen. Als u geen geadresseerde bent, is het niet toegestaan om kennis te nemen van de inhoud, deze te kopieren, te verspreiden, bekend te maken aan derden noch anderszins te gebruiken.
The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please notify us immediately if you have received it in error by reply e-mail and then delete this message from your system. __________________________________________________________
__________________________________________________________ Deze e-mail en de inhoud is vertrouwelijk en uitsluitend bestemd voor de geadresseerde(n). Indien u niet de geadresseerde bent van deze e-mail verzoeken wij u dit direct door te geven aan de verzender door middel van een reply e-mail en de ontvangen e-mail uit uw systemen te verwijderen. Als u geen geadresseerde bent, is het niet toegestaan om kennis te nemen van de inhoud, deze te kopieren, te verspreiden, bekend te maken aan derden noch anderszins te gebruiken.
The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please notify us immediately if you have received it in error by reply e-mail and then delete this message from your system. __________________________________________________________