lang • conv

Conv$

ConvertedString = Conv$ ( String AS String , SourceCharset AS String , DestinationCharset AS String ) AS String ConvertedString = Conv ( String AS String , SourceCharset AS String , DestinationCharset AS String ) AS String

Converts a string from one charset to another charset. A charset is represented by a string like "ASCII", "ISO-8859-1", or "UTF-8".

The Gambas interpreter internally uses the UTF-8 charset.

The charset used by the system is returned by System.Charset. It was ISO-8859-15 on a Mandrake 10.2, but now all Linux systems I know are UTF-8 based.

The charset used by the graphical user interface is returned by Desktop.Charset. It should always be UTF-8.

The conversion uses the iconv() GNU library function and can convert, amongst many other encodings, encoded Turkish (iso-8859-9), Korean (EUC-KR), Simplified Chinese (GB2312), Arabic (windows-1256), Cyrillic (koi8-r) and Japanese (iso-2022-jp) into human-readable UTF-8. For a full list of supported international text conversions type iconv -l in a command line.

Note that not all combinations of encoding names can be used for the SourceCharset and DestinationCharset parameters and that a coded character set can have a number of aliases.

Errors

Message

Description
Bad string conversion (32) The string to convert contains untranslatable characters.
Unsupported string conversion (31) The specified charsets are unknown, or cannot be converted.

Examples

Dim sStr As String
Dim iInd As Integer

sStr = Conv$("Gambas", "ASCII", "EBCDIC-US")

For iInd = 1 To Len(sStr)
  Print Hex$(Asc(Mid$(sStr, iInd, 1)), 2); " ";
Next
C7 81 94 82 81 A2
Print Conv$("����� ��������� ���������� �� ���� 307", "KOI8-R", "UTF-8")
Заказ впускного коллектора на пежо 307

See also