M
M
maiskiykot2018-03-26 18:07:05
PHP
maiskiykot, 2018-03-26 18:07:05

Why doesn't GD2 render russian characters on apache server?

There is a simple script on GD2 - puts inscriptions on the buttons. The site is made on win-1251. The problem is that on localhost this script works fine under PHP 5.6.2. However, on the server, he does not want to render Russian letters. Those. Latin goes with a bang, and Russian - breaks the picture (only a cross remains) and nothing! The question is: what needs to be tweaked on the server to make it work? This script has been thrashing me for 10 years so far.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Boris Korobkov, 2018-03-26
@BorisKorobkov

First, use UTF-8.
Secondly, do not rely on the default font, but explicitly specify the path to the TTF file with the font (after making sure that it supports Cyrillic).

R
Roman, 2018-03-26
@WNeZRoS

The picture breaks most likely due to errors that are sent instead of or along with the picture.
Probably the font was not found or GD2 itself.

X
xmoonlight, 2018-03-26
@xmoonlight

Try converting to unicode:

function unicode_russian($str) {
     $encode = "";
     for ($ii=0;$ii<strlen($str);$ii++) {
         $xchr=substr($str,$ii,1);
         if (ord($xchr)>191) {
             $xchr=ord($xchr)+848;
             $xchr="&#" . $xchr . ";";
         }
         if(ord($xchr) == 168) {
               $xchr = "&#1025;";
         }
         if(ord($xchr) == 184) {
               $xchr = "&#1105;";
         }
         $encode=$encode . $xchr;
   }
     return $encode;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question