Tuesday, August 5, 2008

encode AICC data in JavaScript

The AICC data in putparam command needs to be encoded before send the HTTP request, and there are several JavaScript methods for encoding strings: escape, encodeURI, encodeURIComponent. Here is the article describing the difference between them. However, those 3 doesn't quite meet the requirements, because all of them will skip some unsafe characters. For example, escape and encodeURI will skip the unsafe character "/", and encodeURIComponent will skip the unsafe character "'".

Since "+" will be decoded to spaces on the server, this needs to be encoded before sending the AICC data. This makes escape() the last one we should choose, and encodeURI skips a lot of unsafe characters, besides "+". So it looks like encodeURIComponent is the best choice, but we need to be careful about "'" and "~".

1 comment:

Anonymous said...

Hey,

I am regular visitor of this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]You have really contiributed very good info here jackchang1.blogspot.com. Frankly speaking we really do not pay attention towards our health. Let me show you one truth. Recent Research presents that closely 90% of all U.S. adults are either fat or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these citizens, you're not alone. In fact, most of us need to lose a few pounds once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is really not as tough as you think. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am author of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.