Jump to content

[SOLVED] Character encoding in PHP & GD2?


helraizer

Recommended Posts

Hi all,

 

My Chatbox

 

I have been working on a dynamic image in GD2 which acts as a chatbox in a forum signature.

 

It all seems to be working pretty well, but I have come across a bug (of sorts): if the user were to enter characters such as '¬_¬' the result in the image is shown as 'Ž_Ž'.

 

Is there any way that, using PHP, I can change this so that is actually understands the characters and would print '¬_¬'.?

 

Hope that makes sense.

 

Sam

Link to comment
https://forums.phpfreaks.com/topic/75117-solved-character-encoding-in-php-gd2/
Share on other sites

If I use imagestring() I get the same results as you but if I use a truetype font (arial) it works

 

<?php
$font = 'c:/windows/fonts/arial.ttf';
$im = imagecreate (30,20) ;
$bg = imagecolorallocate($im,0xFF,0xFF,0xFF);
$tc = imagecolorallocate($im,0x00,0x00,0x00); 
imagettftext($im,9,0,5,15,$tc,$font,'¬_¬');
imagepng($im);
imagedestroy($im);

?>

The way my Chatbox works in this instance is that when the user submits the data their username, the color of text and the message are all sent to a .line file. Rather than the text just being put in there and then when the dynamic image is produced.

 

So if I use imagettftext it doesn't work; none of the messages show up on the image.

 

(if you need code to help you understand, just holler and I'll paste)

 

Any ideas?

 

Sam

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.