0

I have to encode this $txt[$y] bellow to utf-8 or ISO-8859-1. I use tFPDF extend with font with have special letters. Right now string is correctly displayed in the cell, but when I use special letters like ś,й,é I can see only question marks:
img here

function magia($txt='', $border=0, $ln=0, $align='C', $fill=false, $link='', $scale=false, $force=true){
    $str_width = $this->GetStringWidth($txt);
    $len = strlen($txt);

    for ($y = 0; $y < $len; $y++){
        $this->Cell(6,6,$txt[$y],0,0,'C');        
    }
}
volker
  • 13
  • 3

1 Answers1

0

Use mb_ functions. PHP is still not full UTF-8 friendly. Doing $x[0] will not work on some special characters. Use for example mb_substr() function to get characters. There is a lot of mb_ string functions equal to normal functions that can operate on selected charsets.

mb_substr($str,1,1) will fetch second letter.

http://php.net/manual/en/function.mb-substr.php

+1 for magia :D

imclickingmaniac
  • 1,467
  • 1
  • 16
  • 28