Hi Brett,
I just noticed that myself. The first RETURN should be RETURN nvl(tcstring,'') -- Duh! (I deleted the first post so nobody uses it)
making it:
I've had some problems with ASC characters below 32 as well as above 128. Excel seems to have it's own way of encoding those. Here's my GetXMLString with m. and a bailout at the top for when CHARTRAN of ASC 32-128 returns empty. Testing on a 100,000 street addresses it cut the time from 90 sec to 6 sec.
LPARAMETERS tcString
Local lcChar, lcString, lcXMLString, lnChar, lnNdx
DO case
case isnull(m.tcString)
RETURN ""
case EMPTY(RTRIM(m.tcString));
OR EMPTY(CHRTRAN(UPPER(m.tcString)," ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-',./|\?;:[]{}_=+)(*^%$#@!~",''))
RETURN m.tcString
otherwise
IF EMPTY(m.tcString)
RETURN ""
ENDIF
m.lcString = RTRIM(m.tcString)
m.lcString = STRTRAN(m.lcString, CHR(38), '&')
m.lcString = STRTRAN(m.lcString, '>', '>')
m.lcString = STRTRAN(m.lcString, '<', '<')
m.lcString = STRTRAN(m.lcString, '"', '"')
IF this.CodePage = 0
m.lcXMLString = ""
FOR m.lnNdx=1 TO LEN(m.lcString)
m.lcChar = SUBSTR(m.lcString, m.lnNdx, 1)
m.lnChar = ASC(m.lcChar)
m.lcXMLString = m.lcXMLString + ICASE(m.lnchar<32,'_x00'+STRCONV(m.lcChar ,15 )+'_',;
BETWEEN(m.lnChar,32, 128), m.lcChar,;
"&#" + TRANSFORM(m.lnChar) + ";")
ENDFOR
ELSE
m.lcXMLString = m.lcString
ENDIF
RETURN m.lcXMLString
endcase
↧