VuGen: HTML/URL/Text Conversion

The web_convert_param function either converts HTML text to plain text or URL, or converts plain text to URL.

HTML format uses codes for some non-alphanumerical characters, such as & for ampersand. URLs do not support non alpha-numerical characters and use the escape sequence %number, to represent them. To use an HTML value in a URL, you must therefore convert it into an escape sequence or plain text. For example, an ampersand is represented in a URL as %26. When you use this function to convert the HTML to plain text, it converts it to the way the character would appear in a browser.

So if you had captured the a variable called pScottString with a web_reg_save_param:


You could simply put a line of code in that looks like this:

web_convert_param("pScottString", "SourceEncoding=HTML", "TargetEncoding=PLAIN", LAST);

and you would end up with the following:


Play around with the SourceEncoding and TargetEncoding going from HTML to URL to PLAIN and mix them up.


Chris Jeans added this:
This function decodes URL encoded strings by changing the %HH characters to the ascii character in a string.

e.g. %2F -> /
int URL_decode(char* string)
    int i;
    char code;
    char stringNew[256];
    char* start = string;
    if (string == NULL) /* don't try to deref NULL ptrs */
    return -1;
    /* walk the source string */
    for (i = 0; *string; string++, i++)
        if( *string == '+' )
        /* '+' changed back to space */
        stringNew[i] = ' ';
        else if ( *string == '%' )
            /* hex-encoded (ASCII) chars restored */
            if (sscanf(string+1, "%2x", &code) != 1)
            code = '?'; /* failed to scan, make it something */
            stringNew[i] = code;
            string +=2; /* hop over the scan chars */
        stringNew[i] = *string;
    stringNew[i] = '\0'; /* make sure new string is terminated */
    sprintf( start, "%s", stringNew );
    return 0;
// Usage example
    int rc;
    char buffer[128];
    // 1098227619000%2F1098278560720%2Foa-inoa-254551
    //sprintf( buffer, "%s", "123%2d123%2d123%2d123" );
    sprintf( buffer, "%s", "1098227619000%2F1098278560720%2Foa-inoa-254551" );
    if( ( rc = URL_decode(buffer) ) != 0 )
        lr_error_message("URL_decode(): rc = %d", rc );
        return rc;
    lr_output_message("buffer: '%s'", buffer );
    return 0;

What's Next?

Did you enjoy this article? Help spread the word by sharing:

Join the Northway Navigator Club today and get access to restricted content including our best tips and tricks. Membership is free! You will also receive free email updates by registering.

Engage in the conversation and leave a comment:

Scott Moore

About Scott Moore (153 articles)

With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events

  • Reuben

    I have a code with ASCII values – u002f.. i want to replace this with the actual symbol ‘/’. what is the vugen function for this.