Search results for 'URLEncode'. 2 post(s) found.
- 2009/03/24 URL Encode, Decode function for MFC
- 2007/10/11 Is there URLEncode function in Javascript ?
Here's the good example for URL Encoding & Decoding.
{
return x > 9 ? x + 55: x + 48;
}
inline BYTE toByte(const BYTE &x)
{
return x > 57? x - 55: x - 48;
}
CString URLDecode(CString sIn)
{
CString sOut;
const int nLen = sIn.GetLength() + 1;
register LPBYTE pOutTmp = NULL;
LPBYTE pOutBuf = NULL;
register LPBYTE pInTmp = NULL;
LPBYTE pInBuf =(LPBYTE)sIn.GetBuffer(nLen);
//alloc out buffer
pOutBuf = (LPBYTE)sOut.GetBuffer(nLen);
if(pOutBuf)
{
pInTmp = pInBuf;
pOutTmp = pOutBuf;
// do encoding
while (*pInTmp)
{
if('%'==*pInTmp)
{
pInTmp++;
*pOutTmp++ = (toByte(*pInTmp)%16<<4) + toByte(*(pInTmp+1))%16;
pInTmp++;
}
else if('+'==*pInTmp)
*pOutTmp++ = ' ';
else
*pOutTmp++ = *pInTmp;
pInTmp++;
}
*pOutTmp = '\0';
sOut.ReleaseBuffer();
}
sIn.ReleaseBuffer();
return sOut;
}
CString URLEncode(CString sIn)
{
CString sOut;
const int nLen = sIn.GetLength() + 1;
register LPBYTE pOutTmp = NULL;
LPBYTE pOutBuf = NULL;
register LPBYTE pInTmp = NULL;
LPBYTE pInBuf =(LPBYTE)sIn.GetBuffer(nLen);
//alloc out buffer
pOutBuf = (LPBYTE)sOut.GetBuffer(nLen*3);
if(pOutBuf)
{
pInTmp = pInBuf;
pOutTmp = pOutBuf;
// do encoding
while (*pInTmp)
{
if(isalnum(*pInTmp) || '-'==*pInTmp || '_'==*pInTmp || '.'==*pInTmp)
*pOutTmp++ = *pInTmp;
else if(isspace(*pInTmp))
*pOutTmp++ = '+';
else
{
*pOutTmp++ = '%';
*pOutTmp++ = toHex(*pInTmp>>4);
*pOutTmp++ = toHex(*pInTmp%16);
}
pInTmp++;
}
*pOutTmp = '\0';
sOut.ReleaseBuffer();
}
sIn.ReleaseBuffer();
return sOut;
}
Above sample code use CString, so if you want to use it on another type of development environment such as gcc or something like that, you need to add some more stuffs because it may not support CString class.
Another posts included in "C, C++"
| KMP String Matching Algorithm (0) | 2010/07/21 |
| How to load HTML resource on MFC ? (0) | 2009/03/23 |
| How to get GM Time as String ? (0) | 2009/03/20 |
| How to call SetTimer function on MFC CDialog class ? (0) | 2008/07/30 |
| How to search file on certain directory ? (0) | 2008/06/16 |
| How to run shell command by MFC ? (0) | 2007/09/09 |
Trackback : Cannot send a trackbact to this post.
EncodeURI() is the answer.
and followings are the usage example:
<script type="text/javascript"><!--
function MoveTab(txtObj, event)
{
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
if (keyCode == 13) do_search();
}
function do_search()
{
if (document.getElementById("keyword").value)
{
self.location = "http://reportbank.com/s_" + EncodeURI(document.getElementById("keyword").value);
}
}
-->
</script>
<div width="100%" align=center>
<font size=+6><strong>ReportBank</strong></font><br>
<br>
<input type=text id=keyword name=keyword size=20 value="<?=$keyword?>" onkeypress="return MoveTab(this, event)">
<input type=button value=" Search " onclick="javascript:do_search()">
<br>
</div>
Another posts included in "HTML, Javascript"
| Two useful string functions - substr & substring (0) | 2008/01/15 |
| Javascript based Regular Expression Tester (0) | 2008/01/15 |
| Javascript based Browser Sniffing (0) | 2008/01/25 |
| Move window (0) | 2007/09/07 |
| How to calculate page loading time ? (0) | 2007/09/07 |
| Number Of Vists (0) | 2007/09/07 |
| Add Message On Mouse Traling (0) | 2007/09/07 |
| Tooltip (0) | 2007/09/07 |
Trackback : Cannot send a trackbact to this post.
-
Subject Buy cheap xanax.
2009/03/12 12:14
Xanax dosage. Order xanax online. Xanax. Geniric xanax. No prescription xanax. Xanax 180 pills. Buy xanax online without a prescription.
-
Subject Buy valium c.o.d..
2009/06/17 07:09
Side effects of valium. Valium during pregnancy. Drug valium. Valium toxicity canine. Valium.
-
Subject Valium.
2009/06/19 14:07
Valium without prescription. Roche valium for sale. Buy valium. Diazepam t quil valrelease valium data sheet. Valium dose appropriate. How long does valium stay. Valium.
-
Subject different money making ideas
2010/01/29 02:15
moneyideas
-
Subject different money making ideas
2010/01/29 10:58
moneyideas
-
Subject different money making ideas
2010/01/31 16:42
moneyideas
-
Subject Cheap phentermine.
2010/02/09 00:14
Cheap phentermine. Catalog phentermine buy cheap phentermine online. Phentermine without an rx cheap prices. Cheap 37 5 phentermine. Buy cheap online phentermine. Phentermine cheap. Cheap phentermine diet pill.
-
Subject Phentermine adipex.
2010/05/13 21:46
Phentermine no prescription.
-
Subject Cheapest phentermine online.
2010/05/17 22:20
Buy phentermine online. Lowes t online phentermine price. Purchasing discount phentermine online. Phentermine pill online d. Cheapest phentermine online. Buy phentermine order cheap online. Order phentermine phentermine online. Wrapper phentermine online.
-
Subject Herbal phentermine.
2010/05/31 19:18
Buy phentermine. Discount phentermine. Phentermine. Compare phentermine price.

Prev

Rss Feed