Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

utf8 compatible mailto

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  

Shoud this patch apply to the next stable smarty release?
Of course!
0%
 0%  [ 0 ]
maybe someday
0%
 0%  [ 0 ]
Not at all!
0%
 0%  [ 0 ]
Total Votes : 0

Author Message
adamx
Smarty n00b


Joined: 19 Nov 2004
Posts: 1

PostPosted: Fri Nov 19, 2004 10:24 pm    Post subject: utf8 compatible mailto Reply with quote

I've made some small changes to the mailto function, so now it won't ruin the higher utf8 charcters in the text. It'll also preserve the &something; characters.

The old part was:

Code:

<         $text_encode = '';
<         for ($x=0; $x < strlen($text); $x++) {
<             $text_encode .= '&#x' . bin2hex($text[$x]).';';
<         }


And the changed version is:
Code:

>         $text_encode = '';
>               $skip = false;
>         for ($x=0; $x < strlen($text); $x++) {
>                       if($skip){$text_encode .= $text[$x]; if($text[$x] == ';'){$skip=false;}}
>             elseif($text[$x] == '&'){$text_encode .= $text[$x];$skip = true;}
>                       elseif($smarty->get_template_vars('utf8') && ((ord($text[$x]) & 0x80) == 0x80)){//if utf8 and is extended character
>                               $text_encode .= $text[$x];
>                       } else {
>                               $text_encode .= '&#x' . bin2hex($text[$x]).';';
>                       }
>         }
>


It takes up the encode from wheader the 'uft8' variable is assigned true to the template.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP