function __construct($from_encoding = null, $convert_html_entities = false) { $this->from_encoding = $from_encoding ? $from_encoding : Encoding::system(); $this->encoding_converter = EncodingConverter::create($this->from_encoding, Utf8::NAME); $this->convert_html_entities = $convert_html_entities; $this->reset(); }
function getCustomArray($_getCustomParams = null) { Server::InitDataBlock(array("INPUTS")); if (empty($_getCustomParams)) { $_getCustomParams = array('', '', '', '', '', '', '', '', '', ''); } for ($i = 0; $i <= 9; $i++) { if (isset($_GET["cf" . $i])) { $_getCustomParams[$i] = Encoding::Base64UrlDecode($_GET["cf" . $i]); } else { if (isset($_POST["p_cf" . $i]) && !empty($_POST["p_cf" . $i])) { $_getCustomParams[$i] = Encoding::Base64UrlDecode($_POST["p_cf" . $i]); } else { if (isset($_POST["form_" . $i]) && !empty($_POST["form_" . $i])) { $_getCustomParams[$i] = $_POST["form_" . $i]; } else { if ((Server::$Inputs[$i]->Type == "CheckBox" || Server::$Inputs[$i]->Type == "ComboBox") && empty($_getCustomParams[$i])) { $_getCustomParams[$i] = "0"; } } } } } return $_getCustomParams; }
public function testRemoveNonPrintableAsciiChars() { $stringWithAllAsciiChars = ""; for ($i = 0; $i < 256; $i++) { $stringWithAllAsciiChars .= chr($i); } $stringWithOnlyPrintableChars = Encoding::toPrintableAscii($stringWithAllAsciiChars); $this->assertEquals(224, strlen($stringWithOnlyPrintableChars)); }
public function encoding($text) { // encoding para ISO 8859-1 return $text; if (strrpos(Run::ENCODING, "utf") != "") { return Encoding::toUTF8($text); } else { return Encoding::toLatin1($text); } }
public function execute($sqlQuery, $sqlParams) { if (empty($sqlQuery)) { throw new \InvalidArgumentException("sqlQuery should not be empty"); } if (!is_array($sqlParams)) { throw new \InvalidArgumentException("sqlParams should be an array"); } $this->sqlQuery = $sqlQuery; $this->sqlParams = Encoding::toUtf8($sqlParams); return $this->prepareAndRun(); }
static function toSlug($string, $space = "-") { $string = Encoding::fixUTF8(Encoding::toUTF8($string)); $string = self::mb_strtolower(self::mb_trim($string)); $string = self::cleanTextHtml($string); if (function_exists('iconv')) { $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string); } $string = preg_replace('/[^a-z0-9 _.-]/', '', $string); $string = preg_replace('/[\\s\\-_]+/', $space, $string); $string = str_replace(' ', $space, $string); return $string; }
public function __construct() { $this->setAutomaticInstallation(true); $this->setUpdatePlan(new LogUpdatePlan()); $this->setDataBackendContainer(new FileDataBackendContainer()); $encoding = null; try { $encoding = Encoding::getInstance("UTF-8"); } catch (UnsupportedEncodingException $e) { trigger_error("UTF-8 is not supported; bav is falling back to ISO-8859-15", E_WARNING); $encoding = Encoding::getInstance("ISO-8859-15"); } $this->setEncoding($encoding); }
public function getAll() { $this->csvArray = array(); $isHeaderLine = true; while (($csvLine = fgets($this->csvFile)) !== false) { $csvLineArray = $this->splitCsvLine($csvLine); if ($isHeaderLine) { $this->setColumnsNames($csvLineArray); $isHeaderLine = false; } else { $this->csvArray[] = $this->mapCsvLineToObject($csvLineArray); } } fclose($this->csvFile); return Encoding::toUtf8($this->csvArray); }
/** * Tests the encode() method. * * @see \Jyxo\Mail\Encoding::encode() */ public function testEncode() { $data = file_get_contents($this->filePath . '/email.html'); foreach ($this->encodings as $encoding) { $encoded = Encoding::encode($data, $encoding, 75, "\n"); $this->assertStringEqualsFile($this->filePath . '/encoding-' . $encoding . '.txt', $encoded); } try { Encoding::encode('data', 'dummy-encoding', 75, "\n"); $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class)); } catch (\PHPUnit_Framework_AssertionFailedError $e) { throw $e; } catch (\Exception $e) { // Correctly thrown exception $this->assertInstanceOf(\InvalidArgumentException::class, $e); } }
/** * Returns the file encoding * * @return Encoding */ static function detect_encoding($path) { $abstract = array(); // We assume that 200 lines are enough for encoding detection. // here we must get at the raw data so we don't use other functions // it's not possible to read x chars as this would not be safe with utf // (chars may be split in the middle) $handle = fopen($path, 'r'); $i = 0; while (($line = fgets($handle)) !== false && $i < 200) { $i++; $abstract[] = $line; } fclose($handle); $abstract = implode($abstract); return Encoding::detect_encoding($abstract); }
function cumulus_update($file) { $infile = fopen($file, 'r'); $firstLine = fgetcsv($infile); $csvArray = array(); while (!feof($infile)) { $assoc = array(); $line = fgetcsv($infile); if ($line[0]) { foreach ($line as $index => $value) { $assoc[$firstLine[$index]] = $value ? Encoding::toUTF8($value) : NULL; } $csvArray[] = $assoc; } } fclose($infile); print_r($csvArray); }
/** * Decompression of deflated string. * * Will attempt to decompress using the RFC 1950 standard, and if that fails * then the RFC 1951 standard deflate will be attempted. Finally, the RFC * 1952 standard gzip decode will be attempted. If all fail, then the * original compressed string will be returned. * * @since 2.8 * * @param string $compressed String to decompress. * @param int $length The optional length of the compressed data. * @return string|bool False on failure. */ public static function decompress($compressed, $length = null) { if (empty($compressed)) { return $compressed; } if (false !== ($decompressed = @gzinflate($compressed))) { return $decompressed; } if (false !== ($decompressed = Encoding::compatible_gzinflate($compressed))) { return $decompressed; } if (false !== ($decompressed = @gzuncompress($compressed))) { return $decompressed; } if (function_exists('gzdecode')) { $decompressed = @gzdecode($compressed); if (false !== $decompressed) { return $decompressed; } } return $compressed; }
/** * * @param type $from * @return Utf8Encoder */ public function encoder($from = null) { $from = $from ? $from : Encoding::system(); return new Utf8Encoder($from); }
/** * Trim, utf8-ify and normalize-newlines for a string. * * @param string $str * @return string */ function air2_str_clean($str) { if (is_null($str) || !is_string($str) || strlen($str) == 0) { return $str; } // UTF8-ify $str = Encoding::convert_to_utf8($str); // normalize newlines $str = air2_normalize_newlines($str); // trim $str = trim($str); return $str; }
if (!empty($groupid) && isset(Server::$Groups[$groupid])) { $html = str_replace("<!--SM_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[0]) ? "none" : "", $html); $html = str_replace("<!--SO_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[1]) ? "none" : "", $html); $html = str_replace("<!--PR_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[2]) ? "none" : "", $html); $html = str_replace("<!--FV_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[4]) ? "none" : "", $html); $html = str_replace("<!--FU_HIDDEN-->", empty(Server::$Groups[$groupid]->ChatFunctions[5]) || !empty($_GET[GET_EXTERN_DYNAMIC_GROUP]) ? "none" : "", $html); $html = str_replace("<!--post_chat_js-->", base64_encode(Server::$Groups[$groupid]->PostJS), $html); } $html = str_replace("<!--TR_HIDDEN-->", strlen(Server::$Configuration->File["gl_otrs"]) > 1 ? "" : "none", $html); $html = str_replace("<!--ET_HIDDEN-->", !empty(Server::$Configuration->File["gl_retr"]) && !empty(Server::$Configuration->File["gl_soct"]) ? "" : "none", $html); } } } $header = IOStruct::GetFile(PATH_TEMPLATES . "header.tpl"); if (isset($_GET[GET_EXTERN_USER_HEADER]) && !empty($_GET[GET_EXTERN_USER_HEADER])) { $header = str_replace("<!--logo-->", "<img src=\"" . Encoding::Base64UrlDecode($_GET[GET_EXTERN_USER_HEADER]) . "\" border=\"0\"><br>", $header); } else { if (!empty(Server::$Configuration->File["gl_cali"])) { $header = str_replace("<!--logo-->", "<img src=\"" . Server::$Configuration->File["gl_cali"] . "\" border=\"0\"><br>", $header); } } if (!empty(Server::$Configuration->File["gl_cahi"])) { $header = str_replace("<!--background-->", "<img src=\"" . Server::$Configuration->File["gl_cahi"] . "\" border=\"0\"><br>", $header); } $html = str_replace("<!--param-->", @Server::$Configuration->File["gl_cpar"], $html); $html = str_replace("<!--header-->", $header, $html); $html = str_replace("<!--server-->", LIVEZILLA_URL, $html); $html = str_replace("<!--html-->", "<html dir=\"" . LocalizationManager::$Direction . "\">", $html); $html = str_replace("<!--rtl-->", To::BoolString(LocalizationManager::$Direction == "rtl"), $html); $html = str_replace("<!--dir-->", LocalizationManager::$Direction, $html); $html = str_replace("<!--url_get_params-->", getParams(), $html);
function _encodeUTF16($string) { $result = $string; if ($this->_defaultEncoding) { switch ($this->_encoderFunction) { case 'iconv': $result = iconv('UTF-16LE', $this->_defaultEncoding, $string); break; case 'mb_convert_encoding': $result = mb_convert_encoding($string, $this->_defaultEncoding, 'UTF-16LE'); break; default: $a = new Encoding(); $a->SetGetEncoding("UTF-16LE") || die("编码名错误"); $a->SetToEncoding("GBK") || die("编码名错误"); $result = $a->EncodeString($string); //$result = $string; } } return $result; }
function InitFeedback($_userInitiated = true) { global $USER; Server::InitDataBlock(array("DBCONFIG")); if (empty(Server::$Configuration->Database["gl_fb"])) { return; } $cid = $USER->Browsers[0]->GetLastActiveChatId(); if ($_userInitiated || !empty($cid)) { if ($_userInitiated || Feedback::GetByChatId($cid) == null) { $langparam = isset($_GET["el"]) ? "&el=" . $_GET["el"] : ""; $value = "0;" . base64_encode(LIVEZILLA_URL . "feedback.php?cid=" . Encoding::Base64UrlEncode($cid) . $langparam); $fovl = new OverlayBox(CALLER_USER_ID, CALLER_BROWSER_ID, $value); $fovl->Id = md5($cid . CALLER_USER_ID . CALLER_BROWSER_ID); $fovl->Save(); $fovl->SetStatus(false); } } }
} $copyright_holders[] = sprintf("<a href='%s'>%s</a>", $org_url, $org_name); } $year = date('Y'); $legal_buf = preg_replace('/<!-- YEAR -->/', $year, $legal_buf); $legal_buf = preg_replace('/<!-- COPYRIGHT_HOLDER -->/', implode(', ', $copyright_holders), $legal_buf); if (!$callback) { ?> <html> <head> <link rel="stylesheet" href="css/pinform.css"/> <style> body { font: 15px Helvetica, Helvetica Neue, Arial, 'sans serif'; } </style> </head> <body> <?php echo $legal_buf; ?> </body> </html> <?php } else { $legal_json = Encoding::json_encode_utf8(array('legal' => $legal_buf)); header("Content-Type: application/json"); echo "{$callback}("; echo $legal_json; echo ")"; }
function woo_pi_encode_transient($var = null) { // Check that the Encoding class by Sebastián Grignoli exists if (file_exists(WOO_PI_PATH . 'classes/Encoding.php')) { include_once WOO_PI_PATH . 'classes/Encoding.php'; if (class_exists('Encoding')) { $encoding = new Encoding(); return $encoding->toUTF8($var); } } else { return $var; } }
function nvweb_content_date_format($format = "", $ts) { global $website; global $session; $out = ''; setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']); if (empty($format)) { $out = date($website->date_format, $ts); } else { if (strpos($format, '%day') !== false || strpos($format, '%month') !== false || strpos($format, '%year4')) { // deprecated: used until Navigate CMS 1.6.7; to be removed in Navigate CMS 2.0 $out = str_replace('%br', '<br />', $format); $out = str_replace('%day', date("d", $ts), $out); $out = str_replace('%month_abr', Encoding::toUTF8(strtoupper(strftime("%b", $ts))), $out); $out = str_replace('%month', date("m", $ts), $out); $out = str_replace('%year4', date("Y", $ts), $out); } else { if (!empty($ts)) { $out = Encoding::toUTF8(strftime($format, intval($ts))); } } } return $out; }
/** * @throws ParseException * @param string $line * @return bool */ public function isMainAgency($line) { if ($this->encoding->strlen($line) < self::TYPE_OFFSET + self::TYPE_LENGTH) { throw new ParseException("Invalid line length."); } return $this->encoding->substr($line, self::ISMAIN_OFFSET, 1) === '1'; }
static function GetBrowserLocalization($country = "") { Server::InitDataBlock(array("LANGUAGES", "COUNTRIES")); $base = @$_SERVER["HTTP_ACCEPT_LANGUAGE"]; $language = str_replace(array(",", "_", " "), array(";", "-", ""), !empty($_GET[GET_EXTERN_USER_LANGUAGE]) ? strtoupper(Encoding::Base64UrlDecode($_GET[GET_EXTERN_USER_LANGUAGE])) : (!empty($base) ? strtoupper($base) : "")); if (strlen($language) > 5 || strpos($language, ";") !== false) { $parts = explode(";", $language); if (count($parts) > 0) { $language = $parts[0]; } else { $language = substr($language, 0, 5); } } if (strlen($language) >= 2) { $parts = explode("-", $language); if (!isset(Server::$Languages[$language])) { $language = $parts[0]; if (!isset(Server::$Languages[$language])) { $language = ""; } } if (count($parts) > 1 && isset(Server::$Countries[$parts[1]])) { $country = $parts[1]; } } else { if (strlen($language) < 2) { $language = ""; } } return array($language, $country); }
public function testGetAliases() { $enc = new Encoding('ISO-8859-1'); $this->assertSame(array('ISO_8859-1', 'latin1'), $enc->getAliases()); }
private static function InitEncoding() { if (self::$encoding == null) { self::SetEncoding(Encoding::UTF_8()); } }
} } else { if (Communication::GetIP() == $visitor->IP) { if (!empty($_POST["p_fu_a"])) { exit(AbortFileUpload($chat, $_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])); } if (!empty($_POST["p_iu"])) { exit(RequestFileUpload($visitor, $chat, $_POST[POST_EXTERN_USER_FILE_UPLOAD_NAME])); } else { $html = IOStruct::GetFile(PATH_TEMPLATES . "upload.tpl"); $html = str_replace("<!--upload-->", IOStruct::GetFile(PATH_TEMPLATES . "file_upload.tpl"), $html); $html = str_replace("<!--action-->", "lz_chat_file_init_upload();", $html); $html = str_replace("<!--connector_script-->", IOStruct::GetFile(TEMPLATE_SCRIPT_CONNECTOR), $html); $html = str_replace("<!--cid-->", Encoding::Base64UrlEncode($chat->ChatId), $html); $html = str_replace("<!--mwidth-->", "max-width:90%;", $html); $html = str_replace("<!--chat_id-->", Encoding::Base64UrlEncode($chat->ChatId), $html); exit(Server::Replace($html)); } } } } } } function StoreFile($_visitor, $_browserId, $_partner, $_fullname, $_chatId) { $filename = IOStruct::GetNamebase($_FILES['form_userfile']['name']); Logging::GeneralLog($filename); if (!IOStruct::IsValidUploadFile($filename)) { return false; } if (empty($_fullname)) {
} }, user_ethnicity : { label : AIR2.Fixtures.FieldLabels['user_ethnicity'], fact_identifier : 'ethnicity' }, birth_year : { label : 'Age' }, tag : { label : 'Tag' }, prj_uuid : { label : 'Project', itemLabels : <?php echo Encoding::json_encode_utf8($prj_names); ?> } }; var app = new AIR2.UI.App({ items: AIR2.SearchPanel({ title : '<?php echo $search_label; ?> ', searchUrl : '<?php echo $search_url; ?>
/** * @access public * @param string $encoding * @throws MailerException */ public function setEncoding($encoding = Encoding::Base64) { if (!Encoding::isValid($encoding)) { throw new MailerException("Invalid Attachment: encoding is invalid", MailerException::InvalidAttachment); } $this->encoding = $encoding; }
/** * Recursively encode array (or string) as UTF8 text * * @param mixed $pm_input Array or string to encode * @return mixed Encoded array or string */ function caEncodeUTF8Deep(&$pm_input) { if (is_string($pm_input)) { $pm_input = Encoding::toUTF8($pm_input); } else { if (is_array($pm_input)) { foreach ($pm_input as &$vm_value) { caEncodeUTF8Deep($vm_value); } unset($vm_value); } else { if (is_object($pm_input)) { $va_keys = array_keys(get_object_vars($pm_input)); foreach ($va_keys as $vs_key) { caEncodeUTF8Deep($pm_input->{$vs_key}); } } } } return $pm_input; }
/** * @throws UnsupportedEncodingException * @param String $encoding */ public function __construct($encoding = 'UTF-8') { parent::__construct($encoding); mb_internal_encoding($encoding); }
private function previousIdentifications($unit) { $dets = array(); $date = array(); $list = $unit->getElementsByTagName('Identification'); if ($list->length > 1) { // This skips all Units that have a single Identification // (which is assumed to be the current identification). foreach ($list as $item) { $preferredflag = $item->getElementsByTagName('PreferredFlag'); if ($preferredflag->length > 0 && in_array($preferredflag->item(0)->nodeValue, array('0', 'FALSE', 'false'))) { // There is a preferred flag and it resolves to FALSE. $det = array(); $nlist = $item->getElementsByTagName('FullScientificNameString'); $det['FullScientificNameString'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $nlist = $item->getElementsByTagName('IdentificationQualifier'); if ($nlist->length > 0) { $det['IdentificationQualifier'] = $nlist->item(0)->nodeValue; $det['IdentificationQualifierInsertionPoint'] = $nlist->item(0)->getAttribute('insertionpoint'); } else { $det['IdentificationQualifier'] = FALSE; $det['IdentificationQualifierInsertionPoint'] = FALSE; } $nlist = $item->getElementsByTagName('NameAddendum'); $det['NameAddendum'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $nlist = $item->getElementsByTagName('HybridFlag'); if ($nlist->length > 0) { $det['HybridFlag'] = $nlist->item(0)->nodeValue; $det['HybridFlagInsertionPoint'] = $nlist->item(0)->getAttribute('insertionpoint'); } else { $det['HybridFlag'] = FALSE; $det['HybridFlagInsertionPoint'] = FALSE; } $nlist = $item->getElementsByTagName('IdentifierRole'); $det['IdentifierRole'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $nlist = $item->getElementsByTagName('IdentifiersText'); $det['IdentifiersText'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $nlist = $item->getElementsByTagName('ISODateTimeBegin'); $det['IdentificationDate'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $date[] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : 'ZZZZ'; $nlist = $item->getElementsByTagName('Notes'); $det['IdentificationNotes'] = $nlist->length > 0 ? $nlist->item(0)->nodeValue : FALSE; $dets[] = $det; } } // previous identifications are sorted by identification date array_multisort($date, SORT_ASC, $dets); $previousDets = array(); foreach ($dets as $index => $det) { $prev = ''; // Scientific name $sciname = $det['FullScientificNameString']; $scinameBits = explode(' ', $sciname); if ($det['HybridFlag'] && $det['HybridFlagInsertionPoint']) { $scinameBits = explode(' ', $sciname); $scinameBits[$det['HybridFlagInsertionPoint'] - 1] = Encoding::toUTF8('×') . $scinameBits[$det['HybridFlagInsertionPoint'] - 1]; $sciname = implode(' ', $scinameBits); } if ($det['IdentificationQualifier'] && $det['IdentificationQualifierInsertionPoint']) { $scinameBits = explode(' ', $sciname); $spacer = $det['IdentificationQualifier'] == '?' ? '' : ' '; $scinameBits[$det['IdentificationQualifierInsertionPoint'] - 1] = $det['IdentificationQualifier'] . $spacer . $scinameBits[$det['IdentificationQualifierInsertionPoint'] - 1]; $sciname = implode(' ', $scinameBits); } if ($det['NameAddendum']) { $sciname .= ' ' . $det['NameAddendum']; } $prev .= $sciname; // Determiner if ($det['IdentifiersText']) { $prev .= ', '; $prev .= $det['IdentifierRole'] == 'conf.' ? 'conf. ' : 'det. '; $identifiers = explode(';', $det['IdentifiersText']); $identifier = explode(',', $identifiers[0]); $prev .= count($identifier) > 1 ? trim($identifier[1]) . ' ' . trim($identifier[0]) : trim($identifier[0]); if (count($identifiers) == 2) { $identifier = explode(',', $identifiers[1]); $prev .= ' & '; $prev .= count($identifier) > 1 ? trim($identifier[1]) . ' ' . trim($identifier[0]) : trim($identifier[0]); } elseif (count($identifiers) > 2) { $prev .= ' et al.'; } } // Determination date if ($det['IdentificationDate']) { $dateBits = explode('-', $det['IdentificationDate']); $date = ''; $day = isset($dateBits[2]) ? $dateBits[2] : FALSE; $month = FALSE; if (isset($dateBits[1])) { switch ($dateBits[1]) { case '01': $month = 'i'; break; case '02': $month = 'ii'; break; case '03': $month = 'iii'; break; case '04': $month = 'iv'; break; case '05': $month = 'v'; break; case '06': $month = 'vi'; break; case '07': $month = 'vii'; break; case '08': $month = 'viii'; break; case '09': $month = 'ix'; break; case '10': $month = 'x'; break; case '11': $month = 'xi'; break; case '12': $month = 'xii'; break; default: break; } } $year = $dateBits[0]; if ($day) { $date = "{$day}.{$month}.{$year}"; } elseif ($month) { $date = "{$month}.{$year}"; } else { $date = $year; } $prev .= ', ' . $date; } if ($det['IdentificationNotes']) { $prev .= ' (' . $det['IdentificationNotes'] . ')'; } $previousDets[] = $prev; } $previousDets = implode('; ', $previousDets); if (substr($previousDets, strlen($previousDets) - 1, 1) != '.') { $previousDets .= '.'; } $ret = array('column' => 'previousIdentifications', 'value' => $previousDets); return $ret; } }