本文整理汇总了PHP中Encoding::toUtf8方法的典型用法代码示例。如果您正苦于以下问题:PHP Encoding::toUtf8方法的具体用法?PHP Encoding::toUtf8怎么用?PHP Encoding::toUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::toUtf8方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($sqlQuery, $sqlParams)
{
if (empty($sqlQuery)) {
throw new \InvalidArgumentException("sqlQuery should not be empty");
}
if (!is_array($sqlParams)) {
throw new \InvalidArgumentException("sqlParams should be an array");
}
$this->sqlQuery = $sqlQuery;
$this->sqlParams = Encoding::toUtf8($sqlParams);
return $this->prepareAndRun();
}
示例2: getAll
public function getAll()
{
$this->csvArray = array();
$isHeaderLine = true;
while (($csvLine = fgets($this->csvFile)) !== false) {
$csvLineArray = $this->splitCsvLine($csvLine);
if ($isHeaderLine) {
$this->setColumnsNames($csvLineArray);
$isHeaderLine = false;
} else {
$this->csvArray[] = $this->mapCsvLineToObject($csvLineArray);
}
}
fclose($this->csvFile);
return Encoding::toUtf8($this->csvArray);
}
示例3: testEncodeComplexItemToUtf8
public function testEncodeComplexItemToUtf8()
{
$latin1 = new \stdClass();
$latin1->n1 = new \stdClass();
$latin1->n = $this->iso88591;
$latin1->n1->n2 = $this->iso88591;
$latin1->a1 = array($this->iso88591, $this->iso88591, "a2" => array($this->iso88591, $this->iso88591), "o" => $latin1->n1);
$utf8 = Encoding::toUtf8($latin1);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->n);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->n1->n2);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1[0]);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1[1]);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["a2"][0]);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["a2"][1]);
$this->assertEquals(Encoding::toUtf8($this->iso88591), $utf8->a1["o"]->n2);
}
示例4: testUtf8InsertionIsNotDoubleEncoded
public function testUtf8InsertionIsNotDoubleEncoded()
{
$stringUtf8 = "des accents en \"utf-8\" : éèàù & Straße";
$columnsToValues = array("intcol" => 7, "utf8col" => Encoding::toUtf8($stringUtf8));
$insertId = $this->db->insert($this->testsTable, $columnsToValues);
$getOneRowSql = "SELECT * FROM {$this->testsTable} WHERE `id` = :id";
$sqlParams = array("id" => $insertId);
$row = $this->db->getOneRow($getOneRowSql, $sqlParams);
$this->assertEquals($stringUtf8, $row->utf8col);
}
示例5: testIsLatin1FileReadAsUtf8
public function testIsLatin1FileReadAsUtf8()
{
$this->csvFile = new CsvFile(__DIR__ . '/Data/iso88591.csv', "\t");
$csvContent = $this->csvFile->getAll();
$this->assertEquals(Encoding::toUtf8("CD-R 52x certifié, 25 pièces en cake box"), $csvContent[0]->ProductName);
}