Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a simple FLL
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Need a simple FLL
Miscellaneous
Thread ID:
01154766
Message ID:
01154766
Views:
91
I need a fast way to convert relatively large ascii strings to their "escaped" hex equivalent for use within dynamically generated javascript. Here I mean where "ABC" becomes "%41%42%43". This will be used as a support routine on a web server for generating portions of web pages that are intentionally obfuscated. It needs to be fast and callable from a VFP COM DLL that is working in conjunction with an ASP app to generate the web pages.

The STRCONV function with opcode of 15 is very close in that it produces an ascii to hex conversion, but it does not include the javascript escape character "%".

What I'm doing now is using STRCONV as above, then passing the result to the browser, and having a browser-side javascript function fix up the string so it can be passed to the unescape function as shown below. Whatever is passed back from the function is either document.written into the page or eval()'d if it's global-scope javascript code rather than HTML.
function HtoE(cStr){
var cNew="";
for (var i=0; i<cStr.length; i=i+2){
  cNew+= "%" + cStr.substr(i,2);
  }
return unescape(cNew);
}
Thanks very much for any suggestions.
Next
Reply
Map
View

Click here to load this message in the networking platform