recodeFileName()
Obsolete function. Converts a string from system encoding (e.g. ISO8859-1) to WinCC OA encoding (e.g. UTF8), function is intended to be used with file names, but can also be used for other strings.
Synopsis
string recodeFileName( string fileName);
Parameters
Parameters | Meaning |
---|---|
fileName |
The name of the file or a string to convert. Note that the name of the file must be specified in ISO8859 encoding. The name must be specified as hexadecimal in the form \x[hexadecimal] e.g. "\xE3\xE4" |
Return value
The function returns the new encoded filename or string.
Error
Invalid or missing arguments
Description
Converts a string from system encoding (e.g. ISO8859-1) to WinCC OA encoding (e.g. UTF8), function is intended to be used with file names, but can also be used for other strings. This function is only relevant, if other functions require a filename or a string in a specific encoding.
Example
The example recodes the file name "Test_with_Umlauts_and_other_characters_\xE3\xE4\xD6\xF1" (ISO8859 as hexadecimal ) to "D:/Test/Test_with_Umlauts_and_other_characters_ãäÖñ.txt". The letters ãäÖñ are output after the call of recodeFileName.
System setting for used codepage must be ISO8859-1 too.
main(mapping event)
{
DebugN("D:/Test/Test_with_Umlauts_and_other_characters_\xE3\xE4\xD6\xF1.txt");
DebugN("RecodeFilename:", recodeFileName("D:/Test/Test_with_Umlauts_and_other_characters_\xE3\xE4\xD6\xF1.txt"));
}
Example
A file (abcd.txt) in ISO8859 format is read and output. The file contains umlauts. These are not shown via the first debug line:
Debug("Content of the file:", st); //Output the content of the file
The umlauts are shown via the second debug line after the call of the "recodeFileName" function:
DebugN("Content of the file after recodeFileName:", fe); //Output the content of the file after recodeFileName
System setting for used codepage must be ISO8859-1 too.
main(mapping event)
{
//File in ISO8859 format in ISO encoding, the file is opened and the strings are recoded.
file f = fopen("D:/Test/abcd.txt","r+");
string fe, st;
while (feof(f)==0) // as long as it is not at the end of the file
{
fgets(st,50,f);
Debug("Content of the file:", st); //Output the content of the file
fe = recodeFileName(st);
DebugN("Content of the file after recodeFileName:", fe); //Output the content of the file after recodeFileName
}
fclose(f); // close file
}
Assignment
Availability
CTRL