Share this page

# Convert encoding formats

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

In this topic:

## Convert the encoding format for strings

Tip: To convert all transaction names in a script to UTF-8 encoding for display in OpenText Performance Engineering solutions, see Convert transaction names to UTF-8 encoding.

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:

LR_ENC_SYSTEM_LOCALE | NULL
LR_ENC_UTF8 | "utf-8"
LR_ENC_UNICODE | "ucs-2"

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

    Action()
    {
        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:

    Output:
    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, the parameter file is saved 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.

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.

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

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

The parameter file is now recognized as UTF-8 text, although it still displays it in regular characters.

Back to top

## Convert transaction names to UTF-8 encoding

By default, ANSI encoding is used for non-English characters included in scripts. ANSI encoding may cause the non-English characters to display incorrectly. For transaction names using non-English characters, you can set the scripts to use Unicode UTF-8 encoding during runtime, to ensure that the characters display correctly.

When the script locale is one of the following, the load generator is able to identify the correct code page to use for the script:

- zh-CN

- ja-JP

- ko-KR

For other locales, by default, the load generator uses the code page for the system locale. Alternatively, in the script file, you can define a specific code page to use.

To specify a code page in the script file:

1. Open the script's .usr file in a text editor.

2. In the General section, add ScriptCodePage=<code page>.

3. Save the file.

Back to top

See also:

- Non-English language support
- Known issues for non-English languages

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1 All View Local Help Center View Online Help Center Version: