|
Home > Archive > dBASE Web Applications > September 2005 > Unescape Carriage and Line feed.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Unescape Carriage and Line feed.
|
|
| Claus Mygind 2005-09-23, 1:23 pm |
| I have been using Bowen's escapeURL( ) function for some time with great
success (see below). Now I would like to pass the content of a memo field
across and his function does a good job of escaping both the carriage return
and line feed %A and %D. However the unescape( ) I use in the javaScript
does not reverse these characters. I suspect I need to use .replace(%A,
replacementString) in my javaScript, the same way I replace the + sign below
with a blank (see script below). How do I replace these non-printable
characters?
puts(' <SCRIPT LANGUAGE="JavaScript">')
puts('function CloseWin(cData) ')
puts('{')
puts([var newData = cData.replace( /\+/g, " ")])
puts([window.opener.document.f1.]+cFieldName+[.value =
unescape(newData)])
puts('window.close()')
puts('}')
puts('</SCRIPT>')
Function escapeURL(cData)
// Bowen Moursund (dBASE, Inc.) NEW - TESTING SEARCH
// March 2000
// Modified MAY 2004 see below
local cRetStr, nLen, cChar, i
cRetStr = ""
nLen = len(cData)
for i = 1 to nLen
cChar = substr(cData, i, 1)
if cChar = " "
// the line below is different than the usual (see commented out line below
that)
cRetStr += "%20"
// cRetStr += "+"
elseif not cChar $
"& =0123456789abcdefghi
jklmnopqrstuvwxyzABC
DEFGHIJKLMNOPQRSTUVW
XYZ"
cRetStr += "%"+itoh(asc(cChar))
else
cRetStr += cChar
endif
next i
return cRetStr
| |
| Claus Mygind 2005-09-23, 1:23 pm |
| Ok! I know how to remove the %A and %D. But I would like to insert a
carriage return and line feed instead of blank space ( see below)
// following line searches and replaces %A with a blank space.
puts([var yData = xData.replace( /%A/g, " ")])
I would like to change that to the line feed for example
cLineFeed = chr(10)
puts([var yData = xData.replace( /%A/g, ]+cLineFeed +[)])
That of course does not work at it causes an immidiate line feed and
unterminated string. So it must have something to do with ITOH and HTOI but
I am not sure how that works.
| |
| Claus Mygind 2005-09-23, 8:23 pm |
| Ok I got it figured out just in case someone else has this problem.
javaScript has a search and replace function like dBASE and you can insert
line feeds and carriage returns like this.
replace the line feed with \n and carriage return with \r, but only one is
really needed. So just remove the other. Be sure to enclose the escape
sequence in " " otherwise you get and instant linefeed and error.
//this line replace the escaped line feed with a carriage return
puts([var yData = xData.replace( /%A/g, "\r")])
//this line just removes the carriage return
puts([var newData = yData.replace( /%D/g, "")])
//restored info is place in text area on web form
puts([window.opener.document.f1.NOTES.value = unescape(newData)])
|
|
|
|
|