Ka Extensions for OpenCart 4

This documentation applies to Ka Extensions for OpenCart 4.x only. It is not compatible with OpenCart 3.

FileUtf8
in component

Reads and writes files in different charsets through UTF-8 conversion filters. It handles BOM and MacOS line endings.

Table of Contents

Properties

Methods

fclose()  : bool
Closes the file.
fopen()  : resource|false|null
Opens a file and appends charset conversion filters.
fseek()  : int
Moves the file pointer to the offset. When conversion filters are applied the file is read from
the beginning up to the offset.
getLastError()  : string
Returns the last error.
rewind()  : void
Moves the file pointer to the beginning of the file data (after BOM).

Properties

$is_filter_applied

protected mixed $is_filter_applied = false

Methods

fclose()

Closes the file.

public fclose() : bool
Return values
bool

fopen()

Opens a file and appends charset conversion filters.

public fopen(mixed $filename, mixed $mode[, mixed $options = array() ][, mixed $charset = 'UTF-8' ]) : resource|false|null

$filename — file path. $mode — 'r', 'w' or 'a'. $options — array of options: enable_macfix — convert MacOS line endings on reading. $charset — file charset.

Parameters
$filename : mixed
$mode : mixed
$options : mixed = array()
$charset : mixed = 'UTF-8'
Return values
resource|false|null —

File handle; false on error (see getLastError()).

fseek()

Moves the file pointer to the offset. When conversion filters are applied the file is read from the beginning up to the offset.

public fseek(mixed $offset) : int

Notes: fseek works in bytes always (regardless of the stream encoding), ftell measures length in bytes for UTF-8 charset, fread reads a number of utf characters (not bytes).

$offset — offset in bytes.

Parameters
$offset : mixed
Return values
int —

0 on success, -1 on error.

getLastError()

Returns the last error.

public getLastError() : string
Return values
string

rewind()

Moves the file pointer to the beginning of the file data (after BOM).

public rewind() : void

        
On this page

Search results