Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automate email
Message
From
25/09/2003 16:22:34
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00826623
Message ID:
00832461
Views:
25
Today I've written a routine that should suffice for email. But I'm not entirely sure about it.
Doubt 1: Is it sufficient to encode only some special characters?
Doubt 2: Did I catch all relevant special characters?

I wonder what you guys have to say about it. (The advantage over Rick's UrlEncode() is speed.)
*	Inspired by the routine UrlEncode from Rick Strahl, but entirely different.
*	See also:
*	http://www.west-wind.com/presentations/shellapi/shellapi.asp
*	http://www.faqs.org/rfcs/rfc2368.html

FUNCTION EncodeForEMail( tcString )

	local lcString

	lcString = strtran( tcString, "%", "%25" )	&& This one must be the first!
	lcString = strtran( lcString, "?", "%3F" )
	lcString = strtran( lcString, "&", "%26" )
	lcString = strtran( lcString, "=", "%3D" )
	lcString = strtran( lcString, chr(13)+chr(10), "%0D%0A" )
	lcString = strtran( lcString, chr(13)        , "%0D%0A" )

	RETURN lcString
>Hi Don,
>
>You're right, it requires encoding of other special charcters also. See URLEncode function in
>Re: How to escape a string for html in VFP8 Thread #774646 Message #774940. It should take care of all special characters encoding.
>
>>Thanks again. I find that it also requires special handling for the "&" character. Are there any others that you know of that won't go through?
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform