Documentation

CharsetConverter extends php_user_filter
in package

Converts resource stream or tabular data content charset.

Table of Contents

Constants

BOM_SEQUENCE  = 'bom_sequence'
FILTERNAME  = 'convert.league.csv'
SKIP_BOM_SEQUENCE  = 'skip_bom_sequence'

Properties

$buffer  : string
$input_encoding  : string
$output_encoding  : string
$skipBomSequence  : bool

Methods

__invoke()  : array<string|int, mixed>
Enable using the class as a formatter for the {@link Writer}.
addBOMSkippingTo()  : Reader
Static method to add the stream filter to a {@link Reader} object to handle BOM skipping.
addTo()  : AbstractCsv
Static method to add the stream filter to a {@link AbstractCsv} object.
appendOnReadTo()  : resource
appendOnWriteTo()  : resource
appendTo()  : resource
DEPRECATION WARNING! This method will be removed in the next major point release.
convert()  : iterable<string|int, mixed>
Converts Csv records collection into UTF-8.
filter()  : int
getFiltername()  : string
Static method to return the stream filter filtername.
inputEncoding()  : self
Sets the records input encoding charset.
onCreate()  : bool
outputEncoding()  : self
Sets the records output encoding charset.
prependOnReadTo()  : resource
prependOnWriteTo()  : resource
prependTo()  : resource
DEPRECATION WARNING! This method will be removed in the next major point release.
register()  : void
Static method to register the class as a stream filter.
appendFilter()  : resource
encodeField()  : array<string|int, mixed>
Walker method to convert the offset and the value of a CSV record field.
filterEncoding()  : string
Filter encoding charset.
filterStream()  : resource
prependFilter()  : resource

Constants

Properties

Methods

__invoke()

Enable using the class as a formatter for the {@link Writer}.

public __invoke(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Return values
array<string|int, mixed>

addBOMSkippingTo()

Static method to add the stream filter to a {@link Reader} object to handle BOM skipping.

public static addBOMSkippingTo(Reader $document[, string $output_encoding = 'UTF-8' ]) : Reader
Parameters
$document : Reader
$output_encoding : string = 'UTF-8'
Return values
Reader

addTo()

Static method to add the stream filter to a {@link AbstractCsv} object.

public static addTo(AbstractCsv $csv, string $input_encoding, string $output_encoding[, array<string|int, mixed>|null $params = null ]) : AbstractCsv
Parameters
$csv : AbstractCsv
$input_encoding : string
$output_encoding : string
$params : array<string|int, mixed>|null = null
Return values
AbstractCsv

appendOnReadTo()

public static appendOnReadTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
TypeError
throws
RuntimeException
Return values
resource

appendOnWriteTo()

public static appendOnWriteTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
TypeError
throws
RuntimeException
Return values
resource

appendTo()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static appendTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource

since version 9.22.0

use League\Csv\CharserConverter::appendOnReadTo() or League\Csv\CharserConverter::appendOnWriteTo() instead

Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
codeCoverageIgnore
see
self::appendOnReadTo()
see
self::appendOnWriteTo()
throws
TypeError
throws
RuntimeException
Return values
resource

convert()

Converts Csv records collection into UTF-8.

public convert(iterable<string|int, mixed> $records) : iterable<string|int, mixed>
Parameters
$records : iterable<string|int, mixed>
Return values
iterable<string|int, mixed>

filter()

public filter(mixed $in, mixed $out, mixed &$consumed, bool $closing) : int
Parameters
$in : mixed
$out : mixed
$consumed : mixed
$closing : bool
Return values
int

getFiltername()

Static method to return the stream filter filtername.

public static getFiltername(string $input_encoding, string $output_encoding) : string
Parameters
$input_encoding : string
$output_encoding : string
Return values
string

inputEncoding()

Sets the records input encoding charset.

public inputEncoding(string $encoding) : self
Parameters
$encoding : string
Return values
self

outputEncoding()

Sets the records output encoding charset.

public outputEncoding(string $encoding) : self
Parameters
$encoding : string
Return values
self

prependOnReadTo()

public static prependOnReadTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
TypeError
throws
RuntimeException
Return values
resource

prependOnWriteTo()

public static prependOnWriteTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
TypeError
throws
RuntimeException
Return values
resource

prependTo()

DEPRECATION WARNING! This method will be removed in the next major point release.

public static prependTo(resource $stream[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource

since version 9.22.0

use League\Csv\CharserConverter::prependOnReadTo() or League\Csv\CharserConverter::prependOnWriteTo() instead

Parameters
$stream : resource
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
codeCoverageIgnore
see
self::prependOnReadTo()
see
self::prependOnWriteTo()
throws
TypeError
throws
RuntimeException
Return values
resource

register()

Static method to register the class as a stream filter.

public static register() : void

appendFilter()

protected final static appendFilter(resource $stream, int $mode[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$mode : int
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
RuntimeException|TypeError
Return values
resource

encodeField()

Walker method to convert the offset and the value of a CSV record field.

protected final encodeField(int|float|string|null $value, int|string $offset) : array<string|int, mixed>
Parameters
$value : int|float|string|null
$offset : int|string
Return values
array<string|int, mixed>

filterEncoding()

Filter encoding charset.

protected final static filterEncoding(string $encoding) : string
Parameters
$encoding : string
Tags
throws
OutOfRangeException

if the charset is malformed or unsupported

Return values
string

filterStream()

protected final static filterStream(resource $stream) : resource
Parameters
$stream : resource
Tags
throws
TypeError
Return values
resource

prependFilter()

protected final static prependFilter(resource $stream, int $mode[, string $input_encoding = 'UTF-8' ][, string $output_encoding = 'UTF-8' ]) : resource
Parameters
$stream : resource
$mode : int
$input_encoding : string = 'UTF-8'
$output_encoding : string = 'UTF-8'
Tags
throws
RuntimeException|TypeError
Return values
resource

        
On this page

Search results