Hi
> No biggie.
Thanks.
Because the same problem happens when a 'ISO-8859-1' user also uses acute accent, umlaut and etc. for the file name, I think that should convert it.
Attached patch is added one function called 'utf8tolocal' in utils.php
This function convert utf-8 to local encoding uses few function, mb_convert_encoding, iconv, recode_string. when any function is not defined, it doesn't convert it.
I tested these function by Japanese, being able to convert correctly was only mb_convert_string. I think that any function is safe in other languages.
Hiro
Index: music.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/music.php,v
retrieving revision 1.1
diff -u -r1.1 music.php
--- music.php 7 Feb 2005 05:00:04 -0000 1.1
+++ music.php 7 Feb 2005 06:28:00 -0000
@@ -102,10 +102,7 @@
global $musicdir;
foreach (preg_split('/\//', substr($this->filename,
strlen($musicdir))) as $dir) {
if (!$dir) continue;
- if (function_exists('mb_convert_encoding'))
- $this->urlfilename .=
'/'.rawurlencode(mb_convert_encoding($dir, fs_encoding, 'UTF-8'));
- else
- $this->urlfilename .= '/'.rawurlencode($dir);
+ $this->urlfilename .= '/'.rawurlencode(utf8tolocal($dir));
}
return(true);
Index: video.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/video.php,v
retrieving revision 1.12
diff -u -r1.12 video.php
--- video.php 6 Feb 2005 19:32:59 -0000 1.12
+++ video.php 7 Feb 2005 06:28:00 -0000
@@ -120,10 +120,7 @@
$this->url = video_url;
foreach (preg_split('/\//', substr($this->filename,
strlen($videodir))) as $dir) {
if (!$dir) continue;
- if (function_exists('mb_convert_encoding'))
- $this->url .= '/'.rawurlencode(mb_convert_encoding($dir,
fs_encoding, 'UTF-8'));
- else
- $this->url .= '/'.rawurlencode($dir);
+ $this->url .= '/'.rawurlencode(utf8tolocal($dir));
}
}
}
Index: includes/utils.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/includes/utils.php,v
retrieving revision 1.13
diff -u -r1.13 utils.php
--- includes/utils.php 30 Nov 2004 07:44:21 -0000 1.13
+++ includes/utils.php 7 Feb 2005 06:28:00 -0000
@@ -123,6 +123,23 @@
}
/*
+ utf8tolocal:
+ returns strings convert UTF-8 to local encoding
+*/
+ function utf8tolocal($str) {
+ if (!defined("fs_encoding") || fs_encoding == '')
+ return $str;
+ if (function_exists('mb_convert_encoding'))
+ return mb_convert_encoding($str, fs_encoding, 'UTF-8');
+ if (function_exists('iconv'))
+ return iconv($int_encoding, fs_encoding, $str);
+ if (function_exists('recode_string'))
+ return recode_string("UTF-8.." . fs_encoding, $str);
+
+ return $str;
+ }
+
+/*
DEBUG:
prints out a piece of data
*/
_______________________________________________ mythtv-users mailing list [email protected] http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
