Convert encoding formats

When working with languages other than English, you may need to convert the encoding for strings or parameter files.

Convert the encoding format for strings

You can manually convert a string from one encoding to another (UTF-8, Unicode, or locale machine encoding) using the lr_convert_string_encoding function with the following syntax:

lr_convert_string_encoding(char * sourceString, char * fromEncoding, char * toEncoding, char * paramName)

The function saves the result string (including its terminating NULL) in the third argument, paramName. It returns a 0 on success and -1 on failure.

The format for the fromEncoding and toEncoding arguments are:


In the following example, lr_convert_string_encoding converts "Hello world" from the system locale to Unicode.

    int rc = 0;
    unsigned long converted_buffer_size_unicode = 0;
    char               *converted_buffer_unicode = NULL;
    rc = lr_convert_string_encoding("Hello world", NULL, LR_ENC_UNICODE, "stringInUnicode");
    if(rc < 0)
        // error
return 0;

In the replay log, the output window shows the following information:

Starting action Action.
Action.c(7): Notify: Saving Parameter "stringInUnicode = H\x00e\x00l\x00l\x00o\x00 \x00w\x00o\x00r\x00l\x00d\x00\\x00"
Ending action Action.

The result of the conversion is saved to the paramName argument.

Back to top

Convert the encoding format for parameter files

The parameter file contains the data for parameters that were defined in the script. This file, stored in the script's folder, has a *.dat extension. When running a script, Vusers use the data to execute actions with varying values.

By default, VuGen saves the parameter file with your machine's encoding. When working with languages other than English, however, in cases where the server expects to receive the string in UTF-8, you may need to convert the parameter file to UTF-8. You can do this directly from Notepad, provided that you are working with Windows 2000 or higher.

To apply UTF-8 encoding to a parameter file:

  1. Select Vuser > Parameter List and view the parameter properties.

  2. In the right pane, locate the parameter file in the File path box.

  3. With the parameter table in view, click Edit in Notepad. Notepad opens with the parameter file in csv format.

  4. In the Save as type box, select All Files.

  5. In the Encoding box, select UTF-8 type encoding.

  6. Click Save. Notepad asks you to confirm the overwriting of the existing parameter file. Click Yes.

  7. VuGen now recognizes the parameter file as UTF-8 text, although it still displays it in regular characters.

Back to top