Convert

Malformed input policy: a string or char array that is not valid UTF-8 raises an exception, while a code point that cannot be encoded (negative, surrogate or greater than U+10FFFF) is replaced with '?'.

Namespace: Com\Tecnick\Unicode

Extends: Encoding

File: Convert.php line 38

Malformed input policy: a string or char array that is not valid UTF-8 raises an exception, while a code point that cannot be encoded (negative, surrogate or greater than U+10FFFF) is replaced with ‘?’.

Tags

Methods

chr()

File: Convert.php line 85

public chr(int $ord) : string

Parameters

  • $ord : int: Unicode character value to convert

Tags

Return values

string —

Returns the unicode string

chrArrToOrdArr()

File: Convert.php line 152

public chrArrToOrdArr(array<string|int, string> $chars) : array<string|int, int>

Parameters

  • $chars : array<string|int, string>: Array of UTF-8 chars

Tags

Return values

array<string|int, int>

getSubUniArrStr()

File: Convert.php line 228

public getSubUniArrStr(array<string|int, string> $uniarr[, int $start = 0 ][, int|null $end = null ]) : string

Parameters

  • $uniarr : array<string|int, string>: The input array of characters
  • $start : int = 0: The position of the starting element
  • $end : int|null = null: The position of the first element that will not be returned. An $end that is not after $start returns an empty string.

Return values

string

hexToStr()

File: Encoding.php line 104

public hexToStr(string $hex) : string

Pairs of characters that are not hexadecimal digits are converted to a NUL byte. An odd number of digits is completed with a trailing zero, as the last digit of the final byte.

Parameters

  • $hex : string: Hex code to convert

Return values

string

latinArrToStr()

File: Encoding.php line 81

public latinArrToStr(array<string|int, int<0, 255>> $latarr) : string

Parameters

  • $latarr : array<string|int, int<0, 255»: Array of Latin1 code points

Return values

string

ord()

File: Convert.php line 105

public ord(string $chr) : int

If more than one character is given, only the first codepoint is returned.

Parameters

  • $chr : string: Unicode character

Tags

Return values

int —

Returns the unicode value

ordArrToChrArr()

File: Convert.php line 170

public ordArrToChrArr(array<string|int, int> $ords) : array<string|int, string>

Parameters

  • $ords : array<string|int, int>: Array of UTF-8 code points

Tags

Return values

array<string|int, string>

strToChrArr()

File: Convert.php line 133

public strToChrArr(string $str) : array<int, string>

Parameters

  • $str : string: String to convert

Tags

Return values

array<int, string>

strToHex()

File: Encoding.php line 91

public strToHex(string $str) : string

Parameters

  • $str : string: String to convert

Return values

string

strToOrdArr()

File: Convert.php line 195

public strToOrdArr(string $str) : array<string|int, int>

Parameters

  • $str : string: String to convert

Tags

Return values

array<string|int, int>

toUTF16BE()

File: Encoding.php line 154

public toUTF16BE(string $str) : string

Parameters

  • $str : string: UTF-8 String to convert

Return values

string —

UTF-16BE encoded string

toUTF8()

File: Encoding.php line 132

public toUTF8(string $str[, null|string|array<string|int, string> $enc = null ]) : string

Parameters

  • $str : string: String to convert
  • $enc : null|string|array<string|int, string> = null: Array or comma separated list string of encodings

Return values

string —

UTF-8 encoded string

uniArrToLatinArr()

File: Encoding.php line 48

public uniArrToLatinArr(array<string|int, int> $ordarr) : array<string|int, int>

A code point that has no Latin1 counterpart is replaced with ‘?’, except U+FFFD REPLACEMENT CHARACTER, which is dropped: the returned array is then shorter than the input one.

Parameters

  • $ordarr : array<string|int, int>: Array containing UTF-8 code points

Return values

array<string|int, int> —

Array containing Latin1 code points