当前位置: 首页>>代码示例>>PHP>>正文


PHP String::utf8_compliant方法代码示例

本文整理汇总了PHP中String::utf8_compliant方法的典型用法代码示例。如果您正苦于以下问题:PHP String::utf8_compliant方法的具体用法?PHP String::utf8_compliant怎么用?PHP String::utf8_compliant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在String的用法示例。


在下文中一共展示了String::utf8_compliant方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assert

 /**
  * Call a web service
  * @param $webServiceRequest WebServiceRequest
  * @return string the result of the web service or null in case of an error.
  */
 function &call(&$webServiceRequest)
 {
     assert(is_a($webServiceRequest, 'WebServiceRequest'));
     switch ($webServiceRequest->getMethod()) {
         case 'POST':
             $result = $this->_callPostWebService($webServiceRequest);
             break;
         case 'GET':
             $result = $this->_callGetWebService($webServiceRequest);
             break;
         default:
             // We currently only support GET and POST requests
             assert(false);
     }
     // Catch web service errors
     $nullVar = null;
     if (!$result) {
         return $nullVar;
     }
     // Clean the result
     $result = stripslashes($result);
     if (Config::getVar('i18n', 'charset_normalization') == 'On' && !String::utf8_compliant($result)) {
         $result = String::utf8_normalize($result);
     }
     return $result;
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:31,代码来源:WebService.inc.php

示例2: XMLParserDOMHandler

 /**
  * Parse an XML file using the specified handler.
  * If no handler has been specified, XMLParserDOMHandler is used by default, returning a tree structure representing the document.
  * @param $file string full path to the XML file
  * @return object actual return type depends on the handler
  */
 function &parse($file)
 {
     $parser =& $this->createParser();
     if (!isset($this->handler)) {
         // Use default handler for parsing
         $handler = new XMLParserDOMHandler();
         $this->setHandler($handler);
     }
     xml_set_object($parser, $this->handler);
     xml_set_element_handler($parser, "startElement", "endElement");
     xml_set_character_data_handler($parser, "characterData");
     import('lib.pkp.classes.file.FileWrapper');
     $wrapper =& FileWrapper::wrapper($file);
     // Handle responses of various types
     while (true) {
         $newWrapper = $wrapper->open();
         if (is_object($newWrapper)) {
             // Follow a redirect
             unset($wrapper);
             $wrapper =& $newWrapper;
             unset($newWrapper);
         } elseif (!$newWrapper) {
             // Could not open resource -- error
             $returner = false;
             return $returner;
         } else {
             // OK, we've found the end result
             break;
         }
     }
     if (!$wrapper) {
         $result = false;
         return $result;
     }
     while (!$wrapper->eof() && ($data = $wrapper->read()) !== false) {
         // if the string contains non-UTF8 characters, convert it to UTF-8 for parsing
         if (Config::getVar('i18n', 'charset_normalization') == 'On' && !String::utf8_compliant($data)) {
             $utf8_last = String::substr($data, String::strlen($data) - 1);
             // if the string ends in a "bad" UTF-8 character, maybe it's truncated
             while (!$wrapper->eof() && String::utf8_bad_find($utf8_last) === 0) {
                 // read another chunk of data
                 $data .= $wrapper->read();
                 $utf8_last = String::substr($data, String::strlen($data) - 1);
             }
             $data = String::utf8_normalize($data);
             // strip any invalid UTF-8 sequences
             $data = String::utf8_bad_strip($data);
             // convert named entities to numeric entities
             $data = strtr($data, String::getHTMLEntities());
         }
         // strip any invalid ASCII control characters
         $data = String::utf8_strip_ascii_ctrl($data);
         if (!xml_parse($parser, $data, $wrapper->eof())) {
             $this->addError(xml_error_string(xml_get_error_code($parser)));
         }
     }
     $wrapper->close();
     $result =& $this->handler->getResult();
     $this->destroyParser($parser);
     if (isset($handler)) {
         $handler->destroy();
         unset($handler);
     }
     return $result;
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:71,代码来源:XMLParser.inc.php

示例3: regexp_split

 /**
  * @see http://ca.php.net/manual/en/function.regexp_split.php
  * @param $pattern string Regular expression
  * @param $subject string String to apply regular expression to
  * @param $limit int Number of times to match; -1 for unlimited
  * @return array Resulting string segments
  */
 static function regexp_split($pattern, $subject, $limit = -1)
 {
     if (PCRE_UTF8 && !String::utf8_compliant($subject)) {
         $subject = String::utf8_bad_strip($subject);
     }
     return preg_split($pattern . PCRE_UTF8, $subject, $limit);
 }
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:14,代码来源:String.inc.php

示例4: dirname

 /**
  * @see Filter::process()
  * @param $citationString string
  * @return MetadataDescription
  */
 function &process($citationString)
 {
     $nullVar = null;
     // Check the availability of perl
     $perlCommand = Config::getVar('cli', 'perl');
     if (empty($perlCommand) || !file_exists($perlCommand)) {
         return $nullVar;
     }
     // Convert to ASCII - Paracite doesn't handle UTF-8 well
     $citationString = String::utf8_to_ascii($citationString);
     // Call the paracite parser
     $wrapperScript = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'paracite.pl';
     $paraciteCommand = $perlCommand . ' ' . escapeshellarg($wrapperScript) . ' ' . $this->getCitationModule() . ' ' . escapeshellarg($citationString);
     $xmlResult = shell_exec($paraciteCommand);
     if (empty($xmlResult)) {
         return $nullVar;
     }
     if (Config::getVar('i18n', 'charset_normalization') == 'On' && !String::utf8_compliant($xmlResult)) {
         $xmlResult = String::utf8_normalize($xmlResult);
     }
     // Create a temporary DOM document
     $resultDOM = new DOMDocument();
     $resultDOM->recover = true;
     $resultDOM->loadXML($xmlResult);
     // Extract the parser results as an array
     $xmlHelper = new XMLHelper();
     $metadata = $xmlHelper->xmlToArray($resultDOM->documentElement);
     // We have to merge subtitle and title as neither OpenURL
     // nor NLM can handle subtitles.
     if (isset($metadata['subtitle'])) {
         $metadata['title'] .= '. ' . $metadata['subtitle'];
         unset($metadata['subtitle']);
     }
     // Break up the authors field
     if (isset($metadata['authors'])) {
         $metadata['authors'] = String::trimPunctuation($metadata['authors']);
         $metadata['authors'] = String::iterativeExplode(array(':', ';'), $metadata['authors']);
     }
     // Convert pages to integers
     foreach (array('spage', 'epage') as $pageProperty) {
         if (isset($metadata[$pageProperty])) {
             $metadata[$pageProperty] = (int) $metadata[$pageProperty];
         }
     }
     // Convert titles to title case
     foreach (array('title', 'chapter', 'publication') as $titleProperty) {
         if (isset($metadata[$titleProperty])) {
             $metadata[$titleProperty] = String::titleCase($metadata[$titleProperty]);
         }
     }
     // Map ParaCite results to OpenURL - null means
     // throw the value away.
     $metadataMapping = array('genre' => 'genre', '_class' => null, 'any' => null, 'authors' => 'au', 'aufirst' => 'aufirst', 'aufull' => null, 'auinit' => 'auinit', 'aulast' => 'aulast', 'atitle' => 'atitle', 'cappublication' => null, 'captitle' => null, 'date' => 'date', 'epage' => 'epage', 'featureID' => null, 'id' => null, 'issue' => 'issue', 'jnl_epos' => null, 'jnl_spos' => null, 'match' => null, 'marked' => null, 'num_of_fig' => null, 'pages' => 'pages', 'publisher' => 'pub', 'publoc' => 'place', 'ref' => null, 'rest_text' => null, 'spage' => 'spage', 'targetURL' => 'url', 'text' => null, 'ucpublication' => null, 'uctitle' => null, 'volume' => 'volume', 'year' => 'date');
     // Ignore 'year' if 'date' is set
     if (isset($metadata['date'])) {
         $metadataMapping['year'] = null;
     }
     // Set default genre
     if (empty($metadata['genre'])) {
         $metadata['genre'] = OPENURL_GENRE_ARTICLE;
     }
     // Handle title, chapter and publication depending on
     // the (inferred) genre. Also instantiate the target schema.
     switch ($metadata['genre']) {
         case OPENURL_GENRE_BOOK:
         case OPENURL_GENRE_BOOKITEM:
         case OPENURL_GENRE_REPORT:
         case OPENURL_GENRE_DOCUMENT:
             $metadataMapping += array('publication' => 'btitle', 'chapter' => 'atitle');
             if (isset($metadata['title'])) {
                 if (!isset($metadata['publication'])) {
                     $metadata['publication'] = $metadata['title'];
                 } elseif (!isset($metadata['chapter'])) {
                     $metadata['chapter'] = $metadata['title'];
                 }
                 unset($metadata['title']);
             }
             $openUrlSchemaName = 'lib.pkp.classes.metadata.openurl.OpenUrlBookSchema';
             $openUrlSchemaClass = 'OpenUrlBookSchema';
             break;
         case OPENURL_GENRE_ARTICLE:
         case OPENURL_GENRE_JOURNAL:
         case OPENURL_GENRE_ISSUE:
         case OPENURL_GENRE_CONFERENCE:
         case OPENURL_GENRE_PROCEEDING:
         case OPENURL_GENRE_PREPRINT:
         default:
             $metadataMapping += array('publication' => 'jtitle');
             if (isset($metadata['title'])) {
                 if (!isset($metadata['publication'])) {
                     $metadata['publication'] = $metadata['title'];
                 } elseif (!isset($metadata['atitle'])) {
                     $metadata['atitle'] = $metadata['title'];
                 }
                 unset($metadata['title']);
//.........这里部分代码省略.........
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:101,代码来源:ParaciteRawCitationNlmCitationSchemaFilter.inc.php

示例5: _cleanCitationString

 /**
  * Take a citation string and clean/normalize it
  * @param $citationString string
  * @return string
  */
 function _cleanCitationString($citationString)
 {
     // 1) If the string contains non-UTF8 characters, convert it to UTF-8
     if (Config::getVar('i18n', 'charset_normalization') && !String::utf8_compliant($citationString)) {
         $citationString = String::utf8_normalize($citationString);
     }
     // 2) Strip slashes and whitespace
     $citationString = trim(stripslashes($citationString));
     // 3) Normalize whitespace
     $citationString = String::regexp_replace('/[\\s]+/', ' ', $citationString);
     return $citationString;
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:17,代码来源:Citation.inc.php

示例6: writeAttribute

 function writeAttribute($xmlWriter, $element, $value)
 {
     if (!is_null($value)) {
         if (Config::getVar('i18n', 'charset_normalization') && !String::utf8_compliant($value)) {
             $value = String::utf8_normalize($value);
             $value = String::utf8_bad_strip($value);
         } else {
             if (!String::utf8_compliant($value)) {
                 $value = String::utf8_bad_strip($value);
             }
         }
         $xmlWriter->writeAttribute($element, $value);
     }
 }
开发者ID:ulsdevteam,项目名称:fullJournalTransfer,代码行数:14,代码来源:XMLAssembler.inc.php

示例7: assert

 /**
  * Call a web service
  * @param $webServiceRequest WebServiceRequest
  * @return string the result of the web service or null in case of an error.
  */
 function &call(&$webServiceRequest)
 {
     assert(is_a($webServiceRequest, 'WebServiceRequest'));
     $usePut = false;
     switch ($webServiceRequest->getMethod()) {
         case 'PUT':
             $usePut = true;
         case 'POST':
             if ($webServiceRequest->getAsync()) {
                 $result = $this->_callPostWebServiceAsync($webServiceRequest, $usePut);
             } else {
                 $result = $this->_callPostWebService($webServiceRequest, $usePut);
             }
             break;
         case 'GET':
             $result = $this->_callGetWebService($webServiceRequest);
             break;
         default:
             // TODO: implement DELETE
             assert(false);
     }
     // Catch web service errors
     $nullVar = null;
     if (!$result) {
         return $nullVar;
     }
     // Clean the result
     if ($webServiceRequest->getCleanResult()) {
         $result = stripslashes($result);
         if (Config::getVar('i18n', 'charset_normalization') == 'On' && !String::utf8_compliant($result)) {
             $result = String::utf8_normalize($result);
         }
     }
     return $result;
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:40,代码来源:WebService.inc.php


注:本文中的String::utf8_compliant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。