|
There=92s a bit more to the issue here than just =switching to convertwords, and I think it=92s worth looking at =deeper=85In this specific case, convertwords happens =to work, but convertchars is actually perfectly fine with replacing one =character with multiple characters. If you want to replace a multiple =character string with one or more other characters, then convertwords is =the tool of choice.convertchars does two relevant =things differently than =convertwords:1) convertchars automatic=ally UNURLs the TO and FROM fields in the table, so =93%26" is treated =as an =93&=94 character rather than the literal ==93%26"2) convertchars treats a =93+=94 in the =93to=94= field like a spaceThere are reasons for these =differences. The UNURLing of TO and FROM allows specification of =invisible characters that you may need to strip out of or add to a data =source. The + to SPACE mapping is a bit more esoteric, but I would bet =the internal WebDNA program uses (or maybe =93used") the same block of =code for interpreting query parameters in a URL - the stuff after the ? =- where spaces are mapped to + characters by the browser. For example ="htt=p://example.com/thispage.dna?user+name=3DJane+Doe=94 gets a =formvariable named =93user name=94 with a value of =93Jane =Doe=94.To illustrate =convertchars vs. convertwords, I spent way too much time working out =these =examples...=97=97Examp=le 1:[table =name=3Dt1&fields=3Dfrom,to]&=%26[/table]CHARS: [convertchars table=3Dt1]L =John & Joanna + Jane[/convertchars]<br>WORDS: =[convertwords table=3Dt1]L John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L John & Joanna + Jane
WORDS: L John %26 Joanna + =JaneNotes:The & was replaced in both =cases, but for convertchars it was replaced with & instead of =literally =%26=97=97Example =2:[table =name=3Dt1&fields=3Dfrom,to]%26=%2526[/table]CHARS: [convertchars =table=3Dt1]L John & Joanna + =Jane[/convertchars]<br>WORDS: [convertwords table=3Dt1]L =John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L John %26 Joanna + Jane
WORDS: L John & Joanna + =JaneNotes:convertchars treats the =93to=94 =value of =93%26=94 as the character =93&=94, and the =93from=94 =value of =93%2526=94 as =93%26=94 (after unurling %25 to =%)convertwords treated =93%26=94 literally as =93%26=94, so =it did not find and replace the & =character=97=97E=xample 3:[table =name=3Dt1&fields=3Dfrom,to]+=%252B[/table]CHARS: [convertchars =table=3Dt1]L John & Joanna + =Jane[/convertchars]<br>WORDS: [convertwords table=3Dt1]L =John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L%2BJohn%2B&%2BJoanna%2B+%2BJane
WORDS: L John & =Joanna %252B JaneNotes:convertchars treats =the =93to=94 value of =93+=94 as the SPACE character, so all spaces were =replaced with %2526, unurled to %2B, and the =93+=94 character was not =replacedconvertwords treated the to and from as entered, =replacing =93+=94 with, literally, ==93%2526"=97=97<=div>Example 4:[table =name=3Dt1&fields=3Dfrom,to]%2B=%252B[/table]CHARS: [convertchars =table=3Dt1]L John & Joanna + =Jane[/convertchars]<br>WORDS: [convertwords table=3Dt1]L =John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L John & Joanna %2B Jane
WORDS: L John & Joanna =+ JaneNotes:convertchars treats the =93to=94= value of =93%2B=94 as the =93+" character, so =93+" was replaced with =%2526, unurled to %2B, and spaces were not =replacedconvertwords found no literal =93%2B=94 strings to =replace=97=97Example 5: [table =name=3Dt1&fields=3Dfrom,to]
'%27
+=%2B
#=%23
%=%25
&%26
!=%21
"=%22
[/table]CHARS: [convertchars =table=3Dt1]L John & Joanna + =Jane[/convertchars]<br>WORDS: [convertwords table=3Dt1]L =John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L+John+&+Joanna+++Jane
WORDS: L John %26 Joanna %2B =JaneNotes:This is Michael's original =example (with =93 + Jane=94 added to the source =string).convertchars treats the =93to=94 value of =93+=94 =as the SPACE character, so:all spaces were replaced with =%2B, unurled to =93+=94the =93&=94 character was =replaced with %26, unurled back to the =93&=94 =characterthe =93+=94 character was not =replacedconvertwords treated the to and from as entered, =so:=spaces were not changedthe =93&=94 character was =replaced with %26the "+=94 character was replaced =with %2BSo, in this case, the results of convertwords =represent the desired =outcome=97=97Exa=mple 6:[table =name=3Dt1&fields=3Dfrom,to]
=91%2527
%2B=%252B
#%2523
%%2525
&=%2526
!%2521
=93=%2522
[/table]CHARS: [convertchars =table=3Dt1]L John & Joanna + =Jane[/convertchars]<br>WORDS: [convertwords table=3Dt1]L =John & Joanna + =Jane[/convertwords]<br>Results:CHARS: L John %26 Joanna %2B Jane
WORDS: L John =%2526 Joanna + JaneNotes:=46rom =example 5, the =93+=94 from value was replaced with =93%2B" and the from ==93%=94 characters were replaced with =93%25"convertchars =treats the =93to=94 value of =93%2B=94 as the =93+" character, =so:all spaces were left alonethe ==93&=94 character was replaced with the desired =93%26", after =unurling =93%25" to =93%"the =93+=94 character was =replaced with the desired =93%2B"convertwords treated the to =and from as entered, so:spaces were not =changedthe =93&=94 character was replaced with %2526 (not =the desired %26)the "+=94 character was not =replacedSo, in this case, the results of convertchars =represent the desired =outcome=97=97Example 7: Results:L John %26 =Joanna %2B JaneNotes:I=92m not sure =of the specifics of the desired mapping beyond what is shown, but if it =is to URL everything except space characters, as it appears, then using =the built in URL then reverting %20 to the space character does the =trick in one line.- Brian =FriesOn Apr 25, 2014, at =12:25 PM, Terry Wilson <terry@terryfic.com> =wrote:Not a =bug. Convertchars is a one to one thing. Convertwords will handle the =%27 etc. that is more than one =character.---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing listOn Apr 24, 2014, at 10:16 =AM, Michael Davis <admin@network13.net> =wrote:Thanks =Stuart. That works. Am I misunderstanding the usage of =convertchars? Or is this a known =bug?Mike---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing listOn Apr 23, 2014, at =2:52 PM, Stuart Tremain <webdna@idfk.com.au> =wrote:Mike =change to =CONVERTWORDS:)---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing listOn 24 Apr 2014, at 2:21 am, Michael Davis =<admin@network13.net> =wrote:Hello,---------------------------------------------------------This message is sent to you because you are subscribed tothe mailing listI=92m getting unexpected behavior =from convertchars:<html><body>[table =name=3Dt1&fields=3Dfrom,to]'%27+=%2B#%23%=%25&%26!=%21"=%22[/table][convertchars table=3Dt1]L John =& =Joanna[/convertchars]</body></html>This is spitting =out:L+John+&+JoannaWhat might I be missing or doing wrong =here?Thanks,Mike.To unsubscribe, E-mail to: archives: http://mail.webdna.us/l=ist/talk@webdna.usBug Reporting: support@webdna.us .To unsubscribe, E-mail to: archives: http://mail.webdna.us/l=ist/talk@webdna.usBug Reporting: support@webdna.us .To unsubscribe, E-mail to: archives: http://mail.webdna.us/l=ist/talk@webdna.usBug Reporting: support@webdna.us .To unsubscribe, E-mail to: archives: http://mail.webdna.us/l=ist/talk@webdna.usBug Reporting: support@webdna.us
DOWNLOAD WEBDNA NOW!
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...