Method

# GuessJapaneseEncoding

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

## Description

Guesses the text encoding used for a sample of Japanese text (2022_JP, EUC, S-JIS, or plain US_ASCII). If it is given a string whose encoding is already known, it returns that encoding. If the encoding is unknown, it assumes the encoding is some Japanese script, and attempts to guess which one.

## Usage

``` xojo
result = GuessJapaneseEncoding(text)
```

| Part   | Type                                                 | Description                                   |
|--------|------------------------------------------------------|-----------------------------------------------|
| result | `TextEncoding</api/text/encoding_text/textencoding>` | The guessed TextEncoding.                     |
| text   | `String</api/data_types/string>`                     | The text whose text encoding will be guessed. |

## Sample code

This example is in the Opening event of a `DesktopTextField</api/user_interface/desktop/desktoptextfield>`.

``` xojo
Var t As TextEncoding
t = GuessJapaneseEncoding("テスト文字列")
Me.Text = t.Base.ToString
```

## 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>` functions; `TextEncoding</api/text/encoding_text/textencoding>` class, `Encodings</api/text/encoding_text/encodings>` module.

</div>
