nur-sery/nur_src/io/Tencoding.php

31 lines
1.1 KiB
PHP

<?php
namespace nur\io;
trait Tencoding {
/** @var string */
protected $ppInputEncoding;
/** @var string */
protected $ppOutputEncoding;
protected function encodingInput__afterSetParametrableParams(array $modifiedKeys): void {
$input_encoding = in_array("input_encoding", $modifiedKeys)? $this->ppInputEncoding: null;
$output_encoding = in_array("output_encoding", $modifiedKeys)? $this->ppOutputEncoding: null;
if ($input_encoding !== null) {
$args = [$input_encoding];
if ($output_encoding !== null) $args[] = $output_encoding;
$this->setEncodingFilter(...$args);
}
}
protected function encodingOutput__afterSetParametrableParams(array $modifiedKeys): void {
$output_encoding = in_array("output_encoding", $modifiedKeys)? $this->ppOutputEncoding: null;
$input_encoding = in_array("input_encoding", $modifiedKeys)? $this->ppInputEncoding: null;
if ($output_encoding !== null) {
$args = [$output_encoding];
if ($input_encoding !== null) $args[] = $input_encoding;
$this->setEncodingFilter(...$args);
}
}
}