The UConverter class

- « IntlPartsIterator::getBreakIterator

- UConverter::__construct »

- PHP Manual
- intl
- The UConverter class

# The UConverter class

(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL >= 3.0.0a1)

## Introduction

## Class synopsis

class UConverter {
/* Constants */
public const int REASON_UNASSIGNED;
public const int REASON_ILLEGAL;
public const int REASON_IRREGULAR;
public const int REASON_RESET;
public const int REASON_CLOSE;
public const int REASON_CLONE;
public const int UNSUPPORTED_CONVERTER;
public const int SBCS;
public const int DBCS;
public const int MBCS;
public const int LATIN_1;
public const int UTF8;
public const int UTF16_BigEndian;
public const int UTF16_LittleEndian;
public const int UTF32_BigEndian;
public const int UTF32_LittleEndian;
public const int EBCDIC_STATEFUL;
public const int ISO_2022;
public const int LMBCS_1;
public const int LMBCS_2;
public const int LMBCS_3;
public const int LMBCS_4;
public const int LMBCS_5;
public const int LMBCS_6;
public const int LMBCS_8;
public const int LMBCS_11;
public const int LMBCS_16;
public const int LMBCS_17;
public const int LMBCS_18;
public const int LMBCS_19;
public const int LMBCS_LAST;
public const int HZ;
public const int SCSU;
public const int ISCII;
public const int US_ASCII;
public const int UTF7;
public const int BOCU1;
public const int UTF16;
public const int UTF32;
public const int CESU8;
public const int IMAP_MAILBOX;
/* Methods */
public __construct(?string `$destination_encoding` = `null`, ?string `$source_encoding` = `null`)
public convert(string `$str`, bool `$reverse` = `false`): string|false
public fromUCallback(
int `$reason`,
array `$source`,
int `$codePoint`,
int `&$error`
): string|int|array|null
public static getAliases(string `$name`): array|false|null
public static getAvailable(): array
public getDestinationEncoding(): string|false|null
public getDestinationType(): int|false|null
public getErrorCode(): int
public getErrorMessage(): ?string
public getSourceEncoding(): string|false|null
public getSourceType(): int|false|null
public static getStandards(): ?array
public getSubstChars(): string|false|null
public static reasonText(int `$reason`): string
public setDestinationEncoding(string `$encoding`): bool
public setSourceEncoding(string `$encoding`): bool
public setSubstChars(string `$chars`): bool
public toUCallback(
int `$reason`,
string `$source`,
string `$codeUnits`,
int `&$error`
): string|int|array|null
public static transcode(
string `$str`,
string `$toEncoding`,
string `$fromEncoding`,
?array `$options` = `null`
): string|false
}

## Predefined Constants

`UConverter::REASON_UNASSIGNED`

`UConverter::REASON_ILLEGAL`

`UConverter::REASON_IRREGULAR`

`UConverter::REASON_RESET`

`UConverter::REASON_CLOSE`

`UConverter::REASON_CLONE`

`UConverter::UNSUPPORTED_CONVERTER`

`UConverter::SBCS`

`UConverter::DBCS`

`UConverter::MBCS`

`UConverter::LATIN_1`

`UConverter::UTF8`

`UConverter::UTF16_BigEndian`

`UConverter::UTF16_LittleEndian`

`UConverter::UTF32_BigEndian`

`UConverter::UTF32_LittleEndian`

`UConverter::EBCDIC_STATEFUL`

`UConverter::ISO_2022`

`UConverter::LMBCS_1`

`UConverter::LMBCS_2`

`UConverter::LMBCS_3`

`UConverter::LMBCS_4`

`UConverter::LMBCS_5`

`UConverter::LMBCS_6`

`UConverter::LMBCS_8`

`UConverter::LMBCS_11`

`UConverter::LMBCS_16`

`UConverter::LMBCS_17`

`UConverter::LMBCS_18`

`UConverter::LMBCS_19`

`UConverter::LMBCS_LAST`

`UConverter::HZ`

`UConverter::SCSU`

`UConverter::ISCII`

`UConverter::US_ASCII`

`UConverter::UTF7`

`UConverter::BOCU1`

`UConverter::UTF16`

`UConverter::UTF32`

`UConverter::CESU8`

`UConverter::IMAP_MAILBOX`

## Table of Contents

- UConverter::__construct — Create UConverter object
- UConverter::convert — Convert string from one charset to another
- UConverter::fromUCallback — Default "from" callback function
- UConverter::getAliases — Get the aliases of the given name
- UConverter::getAvailable — Get the available canonical converter names
- UConverter::getDestinationEncoding — Get the destination encoding
- UConverter::getDestinationType — Get the destination converter type
- UConverter::getErrorCode — Get last error code on the object
- UConverter::getErrorMessage — Get last error message on the object
- UConverter::getSourceEncoding — Get the source encoding
- UConverter::getSourceType — Get the source converter type
- UConverter::getStandards — Get standards associated to converter names
- UConverter::getSubstChars — Get substitution chars
- UConverter::reasonText — Get string representation of the callback reason
- UConverter::setDestinationEncoding — Set the destination encoding
- UConverter::setSourceEncoding — Set the source encoding
- UConverter::setSubstChars — Set the substitution chars
- UConverter::toUCallback — Default "to" callback function
- UConverter::transcode — Convert a string from one character encoding to another