Documentation

UTF8Utils
in package

Table of Contents

Constants

FFFD  = "�"
The Unicode replacement character.

Methods

checkForIllegalCodepoints()  : array<string|int, mixed>
Checks for Unicode code points that are not valid in a document.
convertToUTF8()  : string
Convert data from the given encoding to UTF-8.
countChars()  : int
Count the number of characters in a string.

Constants

FFFD

The Unicode replacement character.

public mixed FFFD = "�"

Methods

checkForIllegalCodepoints()

Checks for Unicode code points that are not valid in a document.

public static checkForIllegalCodepoints(string $data) : array<string|int, mixed>
Parameters
$data : string

A string to analyze

Return values
array<string|int, mixed>

An array of (string) error messages produced by the scanning

convertToUTF8()

Convert data from the given encoding to UTF-8.

public static convertToUTF8(string $data[, string $encoding = 'UTF-8' ]) : string

This has not yet been tested with charactersets other than UTF-8. It should work with ISO-8859-1/-13 and standard Latin Win charsets.

Parameters
$data : string

The data to convert

$encoding : string = 'UTF-8'

A valid encoding. Examples: http://www.php.net/manual/en/mbstring.supported-encodings.php

Return values
string

countChars()

Count the number of characters in a string.

public static countChars(string $string) : int

UTF-8 aware. This will try (in order) iconv, MB, and finally a custom counter.

Parameters
$string : string
Return values
int

        
On this page

Search results