Utility Functions and C Language Reference > Utility Functions: C Language (lr_) > Alphabetical Listing > lr_convert_string_encoding


Converts a string to a different encoding.

C Language

int lr_convert_string_encoding( char *sourceString, char *fromEncoding, char *toEncoding, char *paramName );
Example: lr_convert_string_encoding Parameter Functions


Name Comments
sourceString The string to convert
fromEncoding The encoding of the sourceString
toEncoding The encoding to convert of the string saved in parameter paramName
paramName The name of the parameter in which the destination string will be saved

lr_convert_string_encoding converts a string encoding between the following encodings: System locale, Unicode, and UTF-8. The function saves the result string, including its terminating NULL, in the parameter paramName.

Printable characters in the result string are displayed in VuGen and its logs as the actual characters. Non-printable characters are displayed in Hexadecimal. For example:

rc = lr_convert_string_encoding("A", NULL, LR_ENC_UTF8, "stringInUnicode");

The result string displays as A\x00, and not \x41\x00, because the letter A is a printable character.

Add lr_convert_string_encoding manually to a script when needed. It is not recorded.

Values for 'fromEncoding' and 'toEncoding
Constant Value
LR_ENC_UTF8 "utf-8"

Return Values

This function returns 0 on success and -1 on failure.


All arguments can be parameterized using standard parameterization.