Method

# GetTextConverter

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Creates a `TextConverter</api/text/encoding_text/textconverter>` object for converting between two encodings. It also works if the input encoding and output encoding are the same.

## Usage

``` xojo
result = GetTextConverter(inputEncoding, outputEncoding)
```

| Part           | Type                                                   | Description                                                                                                                                 |
|----------------|--------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| result         | `TextConverter</api/text/encoding_text/textconverter>` | Object of type `TextConverter</api/text/encoding_text/textconverter>`, used to perform conversion from *inputEncoding* to *outputEncoding*. |
| inputEncoding  | `TextEncoding</api/text/encoding_text/textencoding>`   | Input text encoding.                                                                                                                        |
| outputEncoding | `TextEncoding</api/text/encoding_text/textencoding>`   | Output text encoding.                                                                                                                       |

## Notes

Every string may internally have a record of its encoding as well as the bytes that constitute its actual text. In many cases, the encoding is unknown, but any string returned by a `TextConverter</api/text/encoding_text/textconverter>` will have a known encoding, and so will be treated properly by `TextFields</api/user_interface/desktop/desktoptextfield>` and `Graphics.DrawText</api/graphics/graphics>`. This is why it may sometimes be useful to get a `TextConverter</api/text/encoding_text/textconverter>` where the input and output encodings are the same; it provides a way to make sure that your app knows what encoding a string represents.

## Sample code

The following example converts the text in a `TextField</api/user_interface/desktop/desktoptextfield>`:

``` xojo
Var c As TextConverter
c = GetTextConverter(GetTextEncoding(&h500), GetTextEncoding(0))
TextField2.Text = c.Convert(TextField1.Text)
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |

<div class="seealso">

`ConvertEncoding</api/text/encoding_text/convertencoding>`, `DefineEncoding</api/text/encoding_text/defineencoding>`, `Encoding</api/text/encoding_text/encoding>`, `GetFontTextEncoding</api/text/encoding_text/getfonttextencoding>`, `GetInternetTextEncoding</api/text/encoding_text/getinternettextencoding>`, `GetTextEncoding</api/text/encoding_text/gettextencoding>` functions; `TextConverter</api/text/encoding_text/textconverter>`, `TextEncoding</api/text/encoding_text/textencoding>` classes; `Encodings</api/text/encoding_text/encodings>` module.

</div>
