0

I have a string coming from MySql DB, encoded in utf8mb4. I am rendering a pdf with FPDF for PHP, and I tried to convert it with iconv:

iconv('utf8mb4', 'cp1252',$myString);

This fails telling me "Notice: iconv(): Wrong charset, conversion from utf8mb4' tocp1252' is not allowed". If I try with

iconv('utf-8', 'cp1252',$myString);

I get "Notice: iconv(): Detected an illegal character in input string".

Without iconv I get multiple ascii chars in place of special chars, and it is not fine.

Is there any way to output this value correctly?

Nillus
  • 1,131
  • 1
  • 14
  • 32

2 Answers2

1

try this one to IGNORE character which is not allowed in the charset

iconv('utf-8', 'cp1252//IGNORE',$myString);
Hilarius L. Doren
  • 757
  • 1
  • 12
  • 29
0

I tried, it did't work. I solved this by using a version of FPDF that allows utf8: TFPDF. It is fully retrocompatible, provided that you add its new font (ttf).

Nillus
  • 1,131
  • 1
  • 14
  • 32