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
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);

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.