2.1.21.7 ocu_url_encode


Description

Enter text to URL encode or decode

Syntax

void ocu_url_encode( string * pstrText, BOOL bEncode = TRUE )

Parameters

pstrText
[modify] pointer to the input and result string
bEncode
[input] false will do decode instead of encode


Examples

EX1

#include <origin.h>
#include <ocu.h>
void state_search(string strSearch="South Carolina", string strCountry="USA")
{
    //example "http://services.groupkt.com/state/search/IND?text=pradesh"
    string strURL = "http://services.groupkt.com/state/search/";
    strURL += strCountry;
    strURL += "?text=";
    ocu_url_encode(&strSearch);//search text might have spaces
    strURL += strSearch;
    string result;
    int err = okutil_http_get(strURL, &result);
    if( err == 0 )
    {
        Tree tr;
        JSON.FromString(tr, result);
        TreeNode trResult = tr.RestResponse;
        string strRetMsg = trResult.messages._0.strVal;
        out_str(strRetMsg);
        if(strRetMsg.Find("No") < 0)
            out_tree(trResult.result);
    }
    else
        printf("Error %d\n", err);
}

Remark

See Also

Header to Included

ocu.h

Reference