Answer the question
In order to leave comments, you need to log in
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
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).
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.
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 = "Ё";
}
if(ord($xchr) == 184) {
$xchr = "ё";
}
$encode=$encode . $xchr;
}
return $encode;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question