/ lang / conv
Conv$
Syntax

    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 is `ISO-8859-15` on a Mandrake 10.2, but `UTF-8` on a RedHat! In the future, all Linux systems will probably be `UTF-8` based.

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

The conversion relies on the iconv() GNU library function.

### 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
    <hr>C7 81 94 82 81 A2

### See also

Conversion Functions