Mark
Mark

Reputation: 5038

strtoupper doesn't work with iconv/utf8_decode and FPDF

To print special characters to FPDF I can use either:

$this->Cell($w2, 15, iconv('UTF-8', 'windows-1252', $text));

or

$this->Cell($w2, 15, utf8_decode($text));

but neither of those work with strtoupper. Example:

$this->Cell($w2, 15, strtoupper(iconv('UTF-8', 'windows-1252', $text)));
$this->Cell($w2, 15, strtoupper(utf8_decode($text)));

$this->Cell($w2, 15, iconv('UTF-8', 'windows-1252', strtoupper($text)));
$this->Cell($w2, 15, utf8_decode(strtoupper($text)));

Given:

$text = "Conformità";

all of these return:

CONFORMITà

instead of:

CONFORMITÀ

UPDATE

The solutions proposed here or in other answers don't work:

mb_strtoupper($text);
mb_strtoupper($text, 'UTF-8'); 

print

CONFORMITÀ

Upvotes: 1

Views: 544

Answers (2)

mrsgidev
mrsgidev

Reputation: 11

Try the following (it worked for me):

mb_convert_case($your_string, MB_CASE_UPPER, 'ISO-8859-1');

Upvotes: 0

Joffrey Schmitz
Joffrey Schmitz

Reputation: 2438

You need to use the multi-bytes version of the function, mb_strtoupper()

echo strtoupper($text); //CONFORMITà
echo mb_strtoupper($text); //CONFORMITÀ

See PHP documentation : PHP mb_strtoupper()

Upvotes: 0

Related Questions