|
| escaping a carriage return |
 |
Wed, 18 Jul 2007 13:53:17 -050 |
I am having a problem with escaping the carriage return from a memo (aka
longText) field.
I am using Bowen's escapeURL routine (see below). For some reason I get
%D%A when unescaped (which of course is the translation for carriage return
line feed I am sure).
How can I properly escape and unescape this?
Function escapeURL(cData)
// Bowen Moursund (dBASE, Inc.)
// March 2000
local cRetStr, nLen, cChar, i
cRetStr = ""
nLen = len(cData)
for i = 1 to nLen
cChar = substr(cData, i, 1)
if cChar = " "
cRetStr += "+"
elseif not cChar $
"&=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
cRetStr += "%"+itoh(asc(cChar))
else
cRetStr += cChar
endif
next i
return cRetStr
|
| Post Reply
|
| Re: escaping a carriage return |
 |
Wed, 18 Jul 2007 17:21:22 -040 |
Claus Mygind wrote:
> cRetStr += "%"+itoh(asc(cChar))
Does it work if you add the second parameter to the itoh() function?
|
| Post Reply
|
| Re: escaping a carriage return |
 |
Wed, 18 Jul 2007 19:05:21 -050 |
Interesting, but it should capture all non-characters not just the carriage
return.
It is possible that the problem occurs in the unEscape phase. I did observe
that the content which was one line then two carriage returns and then
another line. First word on the last line was email. the "e" was
converted
into a spcial charcter prefaced by the % and of couse there was no line
returns inserted in the converted text.
Well you got me thinking now and that's good.
Thanks for the help.
"Michael Nuwer" <michael@forget.it> wrote in message
news:793NVPYyHHA.696@news-server...
> Claus Mygind wrote:
>
>> cRetStr += "%"+itoh(asc(cChar))
>
> Does it work if you add the second parameter to the itoh() function?
>
>
> cRetStr += "%"+itoh(asc(cChar),2)
|
| Post Reply
|
| Re: escaping a carriage return |
 |
Thu, 19 Jul 2007 05:59:27 -040 |
Claus Mygind wrote:
> Interesting, but it should capture all non-characters not just the
> carriage return.
I'm not sure I understand what your getting at here. The problem I saw
is that the first 16 characters char(1)-char(16) have a leading "0" in
hex, but the function as used by Bowen drops the leading "0". So
char(13) becomes "%D" whereas it should be "%0D"
>
> It is possible that the problem occurs in the unEscape phase.
I tested with webclass.cc's OEMFormat function to unEscape the encoding.
"%D" fails, but "%0D" succeeds. Here is an example
set procedure to :webWizards:webclass.cc addi
o = new CGISession()
clear
for i=9 to 30
cChar = chr(i)
cRetStr = "%"+itoh(asc(cChar))
? ""+i
?? cRetStr at 10
?? asc(o.OEMFormat(cRetStr)) at 15
next
> I did
> observe that the content which was one line then two carriage returns
> and then another line. First word on the last line was email. the
"e"
> was converted into a spcial charcter prefaced by the % and of couse
> there was no line returns inserted in the converted text.
>
> Well you got me thinking now and that's good.
>
> Thanks for the help.
>
> "Michael Nuwer" <michael@forget.it> wrote in message
> news:793NVPYyHHA.696@news-server...
>> Claus Mygind wrote:
>>
>>> cRetStr += "%"+itoh(asc(cChar))
>>
>> Does it work if you add the second parameter to the itoh() function?
>>
>>
>> cRetStr += "%"+itoh(asc(cChar),2)
|
| Post Reply
|
| Re: escaping a carriage return |
 |
Thu, 19 Jul 2007 13:56:53 -050 |
Thanks that would have taken eons for me to figure out. I not sure I
understand your function below. But since you have clarified the problem,
I am sure I can work through it.
"Michael Nuwer" <michael@forget.it> wrote in message
news:dclv82eyHHA.1932@news-server...
> Claus Mygind wrote:
>> Interesting, but it should capture all non-characters not just the
>> carriage return.
>
> I'm not sure I understand what your getting at here. The problem I saw is
> that the first 16 characters char(1)-char(16) have a leading "0"
in hex,
> but the function as used by Bowen drops the leading "0". So
char(13)
> becomes "%D" whereas it should be "%0D"
>
>>
>> It is possible that the problem occurs in the unEscape phase.
>
> I tested with webclass.cc's OEMFormat function to unEscape the encoding.
> "%D" fails, but "%0D" succeeds. Here is an example
>
> set procedure to :webWizards:webclass.cc addi
> o = new CGISession()
> clear
> for i=9 to 30
> cChar = chr(i)
> cRetStr = "%"+itoh(asc(cChar))
> ? ""+i
> ?? cRetStr at 10
> ?? asc(o.OEMFormat(cRetStr)) at 15
> next
>
>
>> I did observe that the content which was one line then two carriage
>> returns and then another line. First word on the last line was email.
>> the "e" was converted into a spcial charcter prefaced by the
% and of
>> couse there was no line returns inserted in the converted text.
>>
>> Well you got me thinking now and that's good.
>>
>> Thanks for the help.
>>
>> "Michael Nuwer" <michael@forget.it> wrote in message
>> news:793NVPYyHHA.696@news-server...
>>> Claus Mygind wrote:
>>>
>>>> cRetStr += "%"+itoh(asc(cChar))
>>>
>>> Does it work if you add the second parameter to the itoh()
function?
>>>
>>>
>>> cRetStr += "%"+itoh(asc(cChar),2)
>>
|
| Post Reply
|
|
|
|
|
|
|
|
|
|