convert_charset
Entity: function

Usage:
String is convert_charset(Start_String, From, To, Error, Default_Char)

This function changes the char set of the string Start_String from the char set From to the char set To. Here From and To are  integers which contain the numbers of char sets. You can select these numbers from this table. The return string is the result of this conversion. Parameter Error is for the error code and Default_Char gives the character which will be used to replace the errors.

If you do not need parameters Error and Default_Char then replace them with _ (Anonymous variable). In such case the project default character will be used for Default_Char and you will lose the error code returned in the variable Error.

The code of the errors which appear in the time of conversion will be returned in the variable Error. This code can be 0 (no errors), 1 (cannot fit in the new set), 2 (Start_String is not in the set From) or 3 (both errors 1 and 2).

If after the conversion some of the characters of the Start_String cannot fit in the char set To then this is error 1.

If some of the characters of the Start_String are not in the set From (or if From is 0 (Unicode) and Start_String is not a correct Unicode string) then this is error 2.

If From is equal to To then Start_String is returned and there is not any check for error 2.
 

Example:

?-
  read(String, "Write something in Russian", s), % let the project char set will be Unicode
  write(String), nl,
  Russian is convert_charset(String, 0, 1, _, _),
  Greek is convert_charset(Russian, 3, 0, _, _),
  write(Greek), nl. % changes the Russian (Cyrillic) letters with Greek letters
 

See also:
char sets  table
char_set_name
convert_UTF8_to_local

Look at the example:
char_sets.spj (in folder Examples)