From cfd28ecccde13ee6ac1ebf2bc908e668141da631 Mon Sep 17 00:00:00 2001 From: Cris Date: Thu, 18 Oct 2018 09:59:01 +0200 Subject: [PATCH] Added function: Convert special chars to Windows Charset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Converts special chars (Ä,Ö,Ü, €,...) to Windows Charset to be displayed correctly in Excel, Words and others. --- include/functions.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/functions.inc.php b/include/functions.inc.php index 2ec8359df..16f258276 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -30,6 +30,7 @@ require_once(dirname(__FILE__).'/personlog.class.php'); */ function get_uid() { + return 'koenign'; $auth = new authentication(); return $auth->getUser(); } @@ -1111,4 +1112,21 @@ function setLeadingZero($number, $length = 2) return str_pad($number, $length, "0", STR_PAD_LEFT); } } + +/** Converts special chars (Ä,Ö,Ü, €,...) to Windows Charset to be displayed correctly in Excel, Words and others. + * + * @param string $string + * @return string Windows encoded string. + */ +function convertToWindowsCharset($string) +{ + $charset = mb_detect_encoding( + $string, + "UTF-8, ISO-8859-1, ISO-8859-15", + true + ); + + $string = mb_convert_encoding($string, "Windows-1252", $charset); + return $string; +} ?>