本文整理汇总了PHP中Functions::is_utf8方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::is_utf8方法的具体用法?PHP Functions::is_utf8怎么用?PHP Functions::is_utf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::is_utf8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_synonym
private function create_synonym($rec)
{
$exclude = array('"species"');
foreach ($rec["synonyms"] as $syn) {
if (in_array($syn["synonym"], $exclude)) {
continue;
}
$synonym = new \eol_schema\Taxon();
if (!Functions::is_utf8($syn["synonym"]) || !Functions::is_utf8($syn["syn_author"])) {
continue;
}
$synonym->taxonID = (string) $syn["syn_id"];
if (self::starts_with_small_letter($syn["synonym"])) {
$parts = explode(" ", $rec["sciname"]);
$syn["synonym"] = $parts[0] . " " . $syn["synonym"];
}
$synonym->scientificName = (string) $syn["synonym"];
$synonym->scientificNameAuthorship = (string) $syn["syn_author"];
$synonym->acceptedNameUsageID = (string) $rec["taxon_id"];
$synonym->taxonomicStatus = "synonym";
$synonym->taxonRemarks = (string) $syn["syn_remark"];
$synonym->furtherInformationURL = (string) $syn["syn_url"];
// special case e.g. http://turbellaria.umaine.edu/turb3.php?action=6&code=1412
if (@$rec["parent_id"] == 10408) {
$rec["parent_id"] = "";
}
$synonym->parentNameUsageID = (string) $rec["parent_id"];
if (!$synonym->scientificName) {
continue;
}
if ($synonym->scientificName == $rec["sciname"]) {
echo "\n alert: synonym == valid name \n";
print_r($rec);
self::save_to_dump($synonym->taxonID, $this->dump_file_synonyms);
continue;
}
if (!isset($this->taxon_ids[$synonym->taxonID])) {
$this->archive_builder->write_object_to_file($synonym);
$this->taxon_ids[$synonym->taxonID] = 1;
self::save_to_dump($synonym->taxonID, $this->dump_file_synonyms);
}
}
}
示例2: write_archive
private function write_archive($taxon)
{
$t = new \eol_schema\Taxon();
$t->taxonID = $taxon['avibaseid'];
$t->scientificName = $taxon['sciname'];
$t->scientificNameAuthorship = $taxon['authorship'];
$t->order = ucfirst(strtolower($taxon['order']));
$t->family = $taxon['family'];
$t->genus = self::get_genus($taxon['sciname']);
$t->furtherInformationURL = self::AVIBASE_SOURCE_URL . $taxon['avibaseid'];
if (!isset($this->taxon_ids[$t->taxonID])) {
$this->taxon_ids[$t->taxonID] = '';
$this->archive_builder->write_object_to_file($t);
}
//write comnames and synonyms
$language_iso_codes = self::language_iso_codes();
foreach ($taxon['comnames'] as $name) {
if (!@$name['comnames']) {
continue;
}
// e.g. http://avibase.bsc-eoc.org/species.jsp?avibaseid=483A2A51F4A5E37E -- see Malayalam
foreach (@$name['comnames'] as $comname) {
if (!($comname = trim($comname))) {
continue;
}
if (!Functions::is_utf8($comname)) {
$comname = utf8_encode($comname);
}
if ($name['lang'] == "Latin") {
if ($t->scientificName == $comname) {
continue;
}
$synonym = new \eol_schema\Taxon();
$synonym->taxonID = strtolower(str_ireplace(" ", "_", $comname));
$synonym->scientificName = $comname;
$synonym->acceptedNameUsageID = $taxon['avibaseid'];
$synonym->taxonomicStatus = "synonym";
if (!isset($this->taxon_ids[$synonym->taxonID])) {
$this->taxon_ids[$synonym->taxonID] = '';
$this->archive_builder->write_object_to_file($synonym);
}
} else {
$v = new \eol_schema\VernacularName();
$v->taxonID = $taxon['avibaseid'];
$v->vernacularName = $comname;
$v->language = $language_iso_codes[$name['lang']];
$id = md5($v->vernacularName);
if (!isset($unique_id[$id])) {
$unique_id[$id] = '';
$this->archive_builder->write_object_to_file($v);
}
}
}
}
}
示例3: get_common_names
function get_common_names($names)
{
// might need or not need this...
$common = utf8_encode($name['commonName']);
if (Functions::is_utf8($common)) {
$arr_names[] = array("name" => Functions::import_decode($common), "language" => $name['xml_lang']);
}
}
示例4: get_texts
private function get_texts($description, $taxon_id, $title, $subject, $code, $reference_ids = null, $agent_ids = null)
{
$description = utf8_encode($description);
if (!Functions::is_utf8($description)) {
return;
}
$mr = new \eol_schema\MediaResource();
if ($reference_ids) {
$mr->referenceID = implode("; ", $reference_ids);
}
if ($agent_ids) {
$mr->agentID = implode("; ", $agent_ids);
}
$mr->taxonID = $taxon_id;
$mr->identifier = $mr->taxonID . "_" . $code;
$mr->type = 'http://purl.org/dc/dcmitype/Text';
$mr->language = 'en';
$mr->format = 'text/html';
$mr->furtherInformationURL = $this->taxon_link["species"] . str_replace("s_", "", $taxon_id);
$mr->description = $description;
$mr->CVterm = $subject;
$mr->title = $title;
$mr->creator = '';
$mr->CreateDate = '';
$mr->modified = '';
$mr->UsageTerms = 'http://creativecommons.org/licenses/by-nc/3.0/';
$mr->Owner = '';
$mr->publisher = '';
$mr->audience = 'Everyone';
$mr->bibliographicCitation = $this->bibliographic_citation;
$this->archive_builder->write_object_to_file($mr);
}
示例5: process_fields
private function process_fields($records, $class, $allowed_fields)
{
foreach ($records as $rec) {
if ($class == "VernacularName") {
$c = new \eol_schema\VernacularName();
} elseif ($class == "Agent") {
$c = new \eol_schema\Agent();
} elseif ($class == "Reference") {
$c = new \eol_schema\Reference();
} elseif ($class == "Taxon") {
$c = new \eol_schema\Taxon();
} elseif ($class == "MeasurementOrFact") {
$c = new \eol_schema\MeasurementOrFact();
} elseif ($class == "Occurrence") {
$c = new \eol_schema\Occurrence();
} elseif ($class == "Distribution") {
$c = new \eol_schema\MediaResource();
} elseif ($class == "Image") {
$c = new \eol_schema\MediaResource();
}
$keys = array_keys($rec);
$save = true;
foreach ($keys as $key) {
$temp = pathinfo($key);
$field = $temp["basename"];
/* resource specifications */
// if($this->resource_id == "345") //3I Interactive resource
// if(true)
// {
// if($class == "Image" && $field == "license") $field = "UsageTerms";
// if($class == "Distribution" && $field == "locality") $field = "Description";
// }
/* end specifications */
// manual adjustment bec. of a typo in meta.xml, without "s"
if ($field == "measurementRemark") {
$field = "measurementRemarks";
}
/*
// sample way to exclude if field is to be excluded
if($field == "attribution") continue; //not recognized in eol: http://indiabiodiversity.org/terms/attribution
*/
if (!in_array($field, $allowed_fields)) {
$this->debug["undefined"][$class][$field] = '';
continue;
}
// some fields have '#', e.g. "http://schemas.talis.com/2005/address/schema#localityName"
$parts = explode("#", $field);
if ($parts[0]) {
$field = $parts[0];
}
if (@$parts[1]) {
$field = $parts[1];
}
$value = trim((string) $rec[$key]);
$value = trim(Functions::import_decode($value));
if (!Functions::is_utf8($value)) {
$save = false;
}
//special arrangement
if ($class == "Reference") {
if ($field == "identifier") {
$this->reference_ids[$value] = '';
}
if ($field == "full_reference") {
if (!$value) {
$full_ref = "";
if ($val = (string) @$rec["http://eol.org/schema/reference/primaryTitle"]) {
$full_ref .= $val;
} elseif ($val = (string) @$rec["http://purl.org/dc/terms/title"]) {
$full_ref .= $val;
}
if ($val = (string) @$rec["http://purl.org/ontology/bibo/pageStart"]) {
$full_ref .= ". Page(s) " . $val;
}
if ($val = (string) @$rec["http://purl.org/ontology/bibo/pageEnd"]) {
$full_ref .= " - " . $val;
}
if ($val = (string) @$rec["http://purl.org/ontology/bibo/volume"]) {
$full_ref .= ". Vol. " . $val;
}
if ($val = (string) @$rec["http://purl.org/dc/terms/publisher"]) {
$full_ref .= ". Publisher: " . $val;
}
if ($val = (string) @$rec["http://purl.org/ontology/bibo/authorList"]) {
$full_ref .= ". Author: " . $val;
}
if ($val = (string) @$rec["http://purl.org/ontology/bibo/editorList"]) {
$full_ref .= ". Editor: " . $val;
}
if ($val = (string) @$rec["http://purl.org/dc/terms/created"]) {
$full_ref .= ". " . $val;
}
if ($val = $full_ref) {
$value = $full_ref;
} else {
echo " -- still blank";
}
}
}
}
//.........这里部分代码省略.........
示例6: get_names
//.........这里部分代码省略.........
$name_string = trim($name_string);
$remarks = "";
if ($comp_rating && $comp_rating != "unknown") {
$remarks .= "Completeness: {$comp_rating}. ";
}
if ($cred_rating && $cred_rating != "unknown") {
$remarks .= "Credibility: {$cred_rating}. ";
}
// if($curr_rating && $curr_rating != "unknown") $remarks .= "Currency: $curr_rating. ";
if (isset($this->comment_links[$name_tsn])) {
foreach ($this->comment_links[$name_tsn] as $comment_id) {
if ($c = @$this->comments[$comment_id]) {
$remarks .= $c . ". ";
}
}
}
$remarks = str_replace("..", ".", $remarks);
$remarks = trim($remarks);
if (isset($this->synonym_of[$name_tsn])) {
static $unavailable_reasons = array('database artifact', 'unavailable, database artifact', 'unavailable, incorrect orig. spelling', 'unavailable, literature misspelling', 'unavailable, suppressed by ruling', 'unavailable, other', 'unjustified emendation', 'nomen dubium', 'homonym (illegitimate)', 'superfluous renaming (illegitimate)');
if (in_array($reason, $unavailable_reasons)) {
continue;
}
$taxon = new \eol_schema\Taxon();
$taxon->taxonID = $name_tsn;
$taxon->scientificName = $name_string;
$taxon->parentNameUsageID = $this->synonym_of[$name_tsn];
$taxon->taxonRank = $this->ranks[$rank_id];
$taxon->taxonRemarks = $remarks;
// $taxon->namePublishedIn = $publications;
$taxon->taxonomicStatus = $reason;
// if(isset($this->locations[$name_tsn])) $taxon->spatial = $this->locations[$name_tsn];
if ($val = @$this->locations[$name_tsn]) {
self::add_string_types($taxon->taxonID, md5($val), $val, "http://eol.org/schema/terms/Present", true);
}
// http://rs.tdwg.org/ontology/voc/SPMInfoItems#Distribution - possible value for ITIS geographic division
if (!Functions::is_utf8($taxon->scientificName)) {
echo "NOT UTF8 SYN: {$name_tsn} : {$taxon->scientificName}\n";
}
$this->archive_builder->write_object_to_file($taxon);
@($this->all_statuses['synonyms'][$validity] += 1);
@($this->all_statuses['synonym_reasons'][$reason] += 1);
} else {
// first loop and find all vernacular names
$vernacular_names = array();
if (isset($this->vernaculars[$name_tsn])) {
foreach ($this->vernaculars[$name_tsn] as $name_hash) {
$vernacular = new \eol_schema\VernacularName();
$vernacular->taxonID = $name_tsn;
$vernacular->vernacularName = $name_hash['name'];
$vernacular->language = self::get_iso_code_for_language($name_hash['language']);
if (!Functions::is_utf8($vernacular->vernacularName)) {
echo "NOT UTF8 VERN: {$name_tsn} : {$vernacular->vernacularName}\n";
}
$this->archive_builder->write_object_to_file($vernacular);
@($this->all_statuses['languages'][$name_hash['language']] += 1);
}
}
$publication_ids = array();
if (isset($this->publication_links[$name_tsn])) {
foreach ($this->publication_links[$name_tsn] as $pub_id) {
if ($p = @$this->publications[$pub_id]) {
if (!isset($written_publication_ids[$pub_id])) {
$reference = new \eol_schema\Reference();
$reference->identifier = $pub_id;
$reference->full_reference = $p;
if (!Functions::is_utf8($reference->full_reference)) {
echo "NOT UTF8 REF: {$name_tsn} : {$reference->full_reference}\n";
}
$this->archive_builder->write_object_to_file($reference);
$written_publication_ids[$pub_id] = 1;
}
$publication_ids[] = $pub_id;
}
}
}
if ($i % 5000 == 0) {
echo "{$i} : {$name_tsn} : {$name_string} : " . time_elapsed() . " : " . memory_get_usage() . "\n";
}
$i++;
$taxon = new \eol_schema\Taxon();
$taxon->taxonID = $name_tsn;
$taxon->scientificName = $name_string;
$taxon->parentNameUsageID = $parent_tsn;
$taxon->taxonRank = $this->ranks[$rank_id];
$taxon->taxonRemarks = $remarks;
$taxon->referenceID = implode(";", $publication_ids);
$taxon->taxonomicStatus = $validity;
// if(isset($this->locations[$name_tsn])) $taxon->spatial = $this->locations[$name_tsn];
if ($val = @$this->locations[$name_tsn]) {
self::add_string_types($taxon->taxonID, md5($val), $val, "http://eol.org/schema/terms/Present", true);
}
if (!Functions::is_utf8($taxon->scientificName)) {
echo "NOT UTF8: {$name_tsn} : {$taxon->scientificName}\n";
}
$this->archive_builder->write_object_to_file($taxon);
@($this->all_statuses['valids'][$validity] += 1);
}
}
}
示例7: format_utf8
private function format_utf8($string)
{
$string = Functions::import_decode($string);
if (!Functions::is_utf8($string)) {
return utf8_encode($string);
}
return $string;
}
示例8: clean_string
private function clean_string($str)
{
$str = trim($str);
if (substr($str, 0, 1) == '"' && substr($str, -1) == '"') {
$str = substr($str, 1, strlen($str) - 2);
}
if (!Functions::is_utf8($str)) {
$str = utf8_encode($str);
}
return trim($str);
}
示例9: format_utf8
function format_utf8($str)
{
if (Functions::is_utf8($str)) {
return $str;
} else {
return utf8_encode($str);
}
}
示例10: format_utf8
private function format_utf8($str)
{
if (!Functions::is_utf8($str)) {
return utf8_encode($str);
}
return $str;
}
示例11: lookup_with_cache_vimeo_call
private static function lookup_with_cache_vimeo_call($vimeo, $command, $param, $options = array())
{
// default expire time is 15 days
if (!isset($options['expire_seconds'])) {
$options['expire_seconds'] = 1296000;
}
//debug orig value = 1296000
if (!isset($options['timeout'])) {
$options['timeout'] = 240;
}
if (!isset($options['cache_path'])) {
$options['cache_path'] = DOC_ROOT . "tmp/cache/";
}
// if(!isset($options['cache_path'])) $options['cache_path'] = "/Volumes/Eli black/eol_cache/"; //debug - only during development
$url = $command . implode("_", $param);
$md5 = md5($url);
$cache1 = substr($md5, 0, 2);
$cache2 = substr($md5, 2, 2);
$options['cache_path'] .= "vimeo/";
if (!file_exists($options['cache_path'])) {
mkdir($options['cache_path']);
}
if (!file_exists($options['cache_path'] . $cache1)) {
mkdir($options['cache_path'] . $cache1);
}
if (!file_exists($options['cache_path'] . "{$cache1}/{$cache2}")) {
mkdir($options['cache_path'] . "{$cache1}/{$cache2}");
}
$cache_path = $options['cache_path'] . "{$cache1}/{$cache2}/{$md5}.cache";
if (file_exists($cache_path)) {
$file_contents = file_get_contents($cache_path);
if (!Functions::is_utf8($file_contents)) {
$file_contents = utf8_encode($file_contents);
}
$obj = json_decode($file_contents);
if ($file_contents || strval($file_contents) == "0") {
$file_age_in_seconds = time() - filemtime($cache_path);
if ($file_age_in_seconds < $options['expire_seconds']) {
return $obj;
}
if ($options['expire_seconds'] === false) {
return $obj;
}
}
@unlink($cache_path);
}
if ($obj = $vimeo->call($command, $param)) {
$file_contents = json_encode($obj);
if ($FILE = Functions::file_open($cache_path, 'w+')) {
fwrite($FILE, $file_contents);
fclose($FILE);
} else {
if (!($h = Functions::file_open(DOC_ROOT . "/public/tmp/cant_delete.txt", 'a'))) {
return;
}
fwrite($h, $cache_path . "\n");
fclose($h);
}
return $obj;
}
return false;
}
示例12: get_texts
private function get_texts($description, $taxon_id, $title, $subject, $code, $reference_ids = null, $agent_ids = null)
{
$description = utf8_encode(self::remove_quotes($description));
$description = str_ireplace("<br>", "xxxyyy", $description);
$description = strip_tags($description);
$description = str_ireplace("xxxyyy", "<br>", $description);
if (in_array($code, $this->media_ids)) {
return;
}
if (!Functions::is_utf8($description)) {
return;
}
$this->media_ids[] = $code;
if (in_array($subject, array("#TypeInformation"))) {
$subject = $this->EOL . $subject;
} else {
$subject = $this->SPM . $subject;
}
$mr = new \eol_schema\MediaResource();
if ($reference_ids) {
$mr->referenceID = implode("; ", $reference_ids);
}
if ($agent_ids) {
$mr->agentID = implode("; ", $agent_ids);
}
$mr->taxonID = $taxon_id;
$mr->identifier = $code;
$mr->type = "http://purl.org/dc/dcmitype/Text";
$mr->language = "en";
$mr->format = "text/html";
$mr->furtherInformationURL = $this->taxon_url . $taxon_id;
$mr->description = (string) $description;
$mr->CVterm = $subject;
$mr->title = $title;
$mr->creator = "";
$mr->CreateDate = "";
$mr->modified = "";
$mr->UsageTerms = "http://creativecommons.org/licenses/by-nc/3.0/";
$mr->Owner = "";
$mr->publisher = "";
$mr->audience = "Everyone";
$mr->bibliographicCitation = "";
$this->archive_builder->write_object_to_file($mr);
}
示例13: get_common_names
function get_common_names($names)
{
$arr_names = array();
if ($names) {
foreach ($names as $name) {
$common = utf8_encode($name['commonName']);
if (Functions::is_utf8($common)) {
$arr_names[] = array("name" => Functions::import_decode($common), "language" => $name['xml_lang']);
} else {
echo "\n not utf8 common name: [" . $common . "]\n";
}
}
}
return $arr_names;
}
示例14: get_contributor_name
private function get_contributor_name($url)
{
$options = array('resource_id' => 'gbif', 'expire_seconds' => false, 'download_wait_time' => 1000000, 'timeout' => 900, 'download_attempts' => 2, 'delay_in_minutes' => 2);
// 15mins timeout
$options = array('resource_id' => 'gbif', 'expire_seconds' => false, 'download_wait_time' => 1000000, 'timeout' => 900);
// 15mins timeout
if ($html = Functions::lookup_with_cache($url, $options)) {
// <title property="dc:title">Herbarium Berolinense - Dataset detail</title>
if (preg_match("/\"dc:title\">(.*?)\\- Dataset detail/ims", $html, $arr)) {
if (!Functions::is_utf8($arr[1])) {
exit("\n culprit is contributor name \n");
}
return Functions::import_decode(trim($arr[1]));
}
}
}
示例15: fix_latin1_mangled_with_utf8_maybe_hopefully_most_of_the_time
function fix_latin1_mangled_with_utf8_maybe_hopefully_most_of_the_time($str)
{
return preg_replace_callback('#[\\xA1-\\xFF](?![\\x80-\\xBF]{2,})#', function ($m) {
// utf8_encode($m[0]);
if (Functions::is_utf8($m[0])) {
$str = utf8_decode($m[0]);
$str = utf8_encode($str);
return $str;
} else {
return utf8_encode($m[0]);
}
}, $str);
}