From 3efbdbf6e8634d36d18574e78f0e7c0cbdecd392 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Wed, 3 Jun 2009 17:09:33 +0200 Subject: [PATCH] [svn r21246] FS#306 - Introducing two conversion functions: api_file_system_encode() and api_file_system_decode(). --- .../lib/multibyte_string_functions.lib.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main/inc/lib/multibyte_string_functions.lib.php b/main/inc/lib/multibyte_string_functions.lib.php index d67411390b..3de8368b9a 100644 --- a/main/inc/lib/multibyte_string_functions.lib.php +++ b/main/inc/lib/multibyte_string_functions.lib.php @@ -229,6 +229,32 @@ function api_xml_http_response_encode($string, $from_encoding = null) { return $string; } +/** + * This function converts a given string to the encoding that filesystem uses for representing file/folder names. + * @param string $string The string being converted. + * @param string $from_encoding The encoding that $string is being converted from. If it is omited, the platform character set is assumed. + * @return string Returns the converted string. + */ +function api_file_system_encode($string, $from_encoding = null) { + if (empty($from_encoding)) { + $from_encoding = api_mb_internal_encoding(); + } + return api_convert_encoding($string, api_get_file_system_encoding(), $from_encoding); +} + +/** + * This function converts a given string from the encoding that filesystem uses for representing file/folder names. + * @param string $string The string being converted. + * @param string $from_encoding The encoding that $string is being converted from. If it is omited, the platform character set is assumed. + * @return string Returns the converted string. + */ +function api_file_system_decode($string, $to_encoding = null) { + if (empty($to_encoding)) { + $to_encoding = api_mb_internal_encoding(); + } + return api_convert_encoding($string, $to_encoding, api_get_file_system_encoding()); +} + /** * ---------------------------------------------------------------------------- * Common multibyte string functions