Thanks for the leads, but the problem with the proposed solution is that the code wrapping the text is used in a generic way. The code processes fields containing data. It wraps text in such a way that it fits the field's dimensions, without word breaks!
Therefore I need the text to remain absolutely unchanged (other than inserting an EOL) and still prevent word breaks.
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.
Greetings
Coen
__________________________________________________________ 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. __________________________________________________________
On Tue, 5 Feb 2008, C. Schalkwijk wrote:
Thanks for the leads, but the problem with the proposed solution is that the code wrapping the text is used in a generic way. The code processes fields containing data. It wraps text in such a way that it fits the field's dimensions, without word breaks!
Therefore I need the text to remain absolutely unchanged (other than inserting an EOL) and still prevent word breaks.
I dont see how that could work. Do you know how long your words are?
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.
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. __________________________________________________________
On Tue, Feb 05, 2008 at 01:54:28PM +0100, C. Schalkwijk wrote:
What if I _want_ my text to indent?
then you can't use %=s how should the function know wether a space is there for indenting or not. it can't.
(I want my code to think for me, only when requested).
but that's exactly what you are requestion when you use %=s it implies that you expect pike to handle the wrapping and formatting for you.
Sprintf should be a 'dumb' function and just apply the format I ask for, nothing more.
with %=s you are asking for a wordwrapped block without indenting.
greetings, martin.
We should grab a beer and discus this further some day :) For now: I guess I'll have to write my own wrapping function.
Coen
Martin Bähr wrote:
On Tue, Feb 05, 2008 at 01:54:28PM +0100, C. Schalkwijk wrote:
What if I _want_ my text to indent?
then you can't use %=s how should the function know wether a space is there for indenting or not. it can't.
(I want my code to think for me, only when requested).
but that's exactly what you are requestion when you use %=s it implies that you expect pike to handle the wrapping and formatting for you.
Sprintf should be a 'dumb' function and just apply the format I ask for, nothing more.
with %=s you are asking for a wordwrapped block without indenting.
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. __________________________________________________________
On Tue, Feb 05, 2008 at 02:12:12PM +0100, C. Schalkwijk wrote:
We should grab a beer and discus this further some day :)
i don't drink beer, but i'd be happy to discuss this some time, because i don't think your expectation is unreasonable. it's just not what %=s provides.
greetings, martin.
We should grab a beer and discus this further some day :) For now: I guess I'll have to write my own wrapping function.
I'm not sure i've an opinion about this sprintf stuff, since i didn't even knew it existed.
However, i'd be very pleased to share a beer or two.
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. __________________________________________________________
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. __________________________________________________________
Ok, that was what I thought initially. In that case however, I think that sprintf("%/-*s", length, s) will do. Maybe (s / length)*"\n"+"\n" is the simpler approach then.
arne
On Thu, 7 Feb 2008, C. Schalkwijk wrote:
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. __________________________________________________________
Thank you for your suggestion. They both however breaks up words.
if the text is
"hello how are you today" and the width is set to 6, I want it to become
"hello how are you today"
and not
"hello how ar e you t oday"
Sorry...
Arne Goedeke wrote:
Ok, that was what I thought initially. In that case however, I think that sprintf("%/-*s", length, s) will do. Maybe (s / length)*"\n"+"\n" is the simpler approach then.
arne
On Thu, 7 Feb 2008, C. Schalkwijk wrote:
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. __________________________________________________________
__________________________________________________________ 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. __________________________________________________________
pike-devel@lists.lysator.liu.se