[ '日本語', 'UTF-8', 'SJIS', null, false ], 'invalid test UTF-8 to SJIS (dots as code point)' => [ '❶', 'UTF-8', 'SJIS', 0x2234, ['❶'] ], 'invalid test UTF-8 to SJIS (dots as string)' => [ '❶', 'UTF-8', 'SJIS', '∴', ['❶'] ], 'invalid test UTF-8 to SJIS (none)' => [ '❶', 'UTF-8', 'SJIS', 'none', ['❶'] ], 'invalid test UTF-8 to SJIS (long)' => [ '❶', 'UTF-8', 'SJIS', 'long', ['❶'] ], 'invalid test UTF-8 to SJIS (entity)' => [ '❶', 'UTF-8', 'SJIS', 'entity', ['❶'] ], ]; } /** * Undocumented function * * @covers ::checkConvertEncoding * @dataProvider checkConvertEncodingProvider * @testdox check encoding convert from $from_encoding to $to_encoding [$_dataName] * * @param string $input * @param string $from_encoding * @param string $to_encoding * @param string|int|null $error_char * @param array|bool $expected * @return void */ public function testCheckConvertEncoding( string $input, string $from_encoding, string $to_encoding, $error_char, $expected ): void { $current_subsitute_character = mb_substitute_character(); if ($error_char !== null) { \CoreLibs\Check\Encoding::setErrorChar($error_char); if (!in_array($error_char, ['none', 'long', 'entity'])) { $this->assertEquals( \IntlChar::chr($error_char), \CoreLibs\Check\Encoding::getErrorChar() ); } else { $this->assertEquals( $error_char, \CoreLibs\Check\Encoding::getErrorChar() ); } } $return = \CoreLibs\Check\Encoding::checkConvertEncoding($input, $from_encoding, $to_encoding); $this->assertEquals( $expected, $return ); // reset after test mb_substitute_character($current_subsitute_character); } } // __END__