This site is compatible with Mozilla firefox, Opera, Safari, and Internet Explorer version 7.0 or higher.

howto : Drupal CJK filename dropped.

reason : Drupal using basename() function on filename extracting. But basename function with php5 is not safe locale. If you use utf-8 encoding on cjk like charset, basename will not work exatly.

solution : First. don't use php5, and use php4.
Second. make locale indepent basename function (ex: drupal_basename() )

function drupal_basename($path,$prefix = '') {
  $path = preg_replace('|^.+[\\/]|', '', $path);

  if ($prefix) {
    $path = preg_replace('|'. preg_quote($prefix) .'$|', '', $path);
  }
  return $path;
}

I changed pattern '|^.+[\\/]|' to '/([^\/]+)\//'.

function drupal_basename($path,$suffix = '') {
  $path = preg_replace('/([^\/]+)\//', '', $path);

  if ($suffix) {
    $path = preg_replace('/'.preg_quote($suffix).'$/', '', $path);
  }
  return $path;
}

And replace three files to use drupal_basename function.
* file.inc
* common.inc
* locale.inc

Reference : http://drupal.org/node/278425

Trackback URL for this post:

http://barami.org/trackback/67

Comments

Post new comment