Development

#2 (the _encodeText() function is not utf8-safe)

You must first sign up to be able to contribute.

Ticket #2 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

the _encodeText() function is not utf8-safe

Reported by: francois Assigned to:
Priority: minor Milestone: 1.0.0
Component: Version: 0.4.0
Keywords: helper Cc:
Qualification:

Description

The _encodeText() function used by the URL Helpers doesn't encode properly non-ascii characters. As a consequence, the mail_to() helper doesn't work for utf8 characters.

example string that doesn't output properly in _encodeText() : 'déjà vu'

Change History

01/30/06 19:12:16 changed by spascoe

At http://us2.php.net/manual/en/function.ord.php#46267 is a uniord function that apparently correctly encodes UNICODE characters.

I've pasted it here:

/**
 * @Algorithm: http://www1.tip.nl/~t876506/utf8tbl.html
 * @Logic: UTF-8 to Unicode conversion
 **/
function uniord($c)
{
  $ud = 0;
  if (ord($c{0})>=0 && ord($c{0})<=127)
   $ud = ord($c{0});
  if (ord($c{0})>=192 && ord($c{0})<=223)
   $ud = (ord($c{0})-192)*64 + (ord($c{1})-128);
  if (ord($c{0})>=224 && ord($c{0})<=239)
   $ud = (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
  if (ord($c{0})>=240 && ord($c{0})<=247)
   $ud = (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
  if (ord($c{0})>=248 && ord($c{0})<=251)
   $ud = (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
  if (ord($c{0})>=252 && ord($c{0})<=253)
   $ud = (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
  if (ord($c{0})>=254 && ord($c{0})<=255) //error
   $ud = false;
 return $ud;
}

I plan to try it later to see if it actually works as advertised, but wanted to update this ticket.

04/10/06 11:09:37 changed by fabien

  • milestone changed from 0.6.0 to 1.0.0.

04/26/06 13:39:01 changed by francois

  • status changed from new to closed.
  • resolution set to fixed.

in r1282