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


PHP Encoding::toLatin1方法代码示例

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


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

示例1: encoding

 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);
     }
 }
开发者ID:obscurun,项目名称:run-dev,代码行数:10,代码来源:string.php

示例2: basename

 $xml_content = simplexml_load_file($dir . basename($file));
 $authors = $xml_content->feature[0]['authors'];
 $title = $xml_content->feature[0]['title'];
 for ($i = 2; $i < count($xml_content); $i++) {
     $type = (string) $xml_content->feature[$i]['type'];
     $obfuscation = (string) $xml_content->feature[$i]['manual_obfuscation'];
     $this_lang = (string) $xml_content->feature[$i]['this_language'];
     $src_lang = (string) $xml_content->feature[$i]['source_language'];
     $this_offset = intval($xml_content->feature[$i]['this_offset']);
     $this_lenght = intval($xml_content->feature[$i]['this_length']);
     $src_offset = intval($xml_content->feature[$i]['source_offset']);
     $src_lenght = intval($xml_content->feature[$i]['source_length']);
     $src_txt = (string) $xml_content->feature[$i]['source_reference'];
     $src_ref = (string) basename($src_txt, '.txt');
     $src_content = loadFile($src_dir . $src_txt);
     $this_feature_content = $encode->toUTF8(substr($encode->toLatin1($this_content), $this_offset, $this_lenght));
     $src_feature_content = $encode->toUTF8(substr($encode->toLatin1($src_content), $src_offset + 1, $src_lenght + 1));
     writeFile($this_lang . '/SUSP_' . $j . '_' . ($i - 2) . '.txt', $this_feature_content);
     writeFile($src_lang . '/SRC_' . $j . '_' . ($i - 2) . '.txt', $src_feature_content);
     $noiseNumber = substr_count($this_feature_content, ' vna ');
     $noiseNumber += substr_count($this_feature_content, ' vn ');
     $noiseNumber += substr_count($this_feature_content, ' i ');
     $noise = $noiseNumber >= 5 ? 'true' : 'false';
     $textualEquivalent = new TextualEquivalent($name, $this_lang, $this_offset, $this_lenght, $this_feature_content, $src_ref, $src_lang, $src_offset, $src_lenght, $src_feature_content, $type, $obfuscation, $noise);
     $string = '<?xml version="1.0" encoding="UTF-8"?>' . chr(10);
     $string .= '<info>' . chr(10);
     $string .= '<sourceIDDoc>' . $src_ref . '</sourceIDDoc>' . chr(10);
     $string .= '<sourceTextLanguage>' . $src_lang . '</sourceTextLanguage>' . chr(10);
     $string .= '<sourceTextOffset>' . $src_offset . '</sourceTextOffset>' . chr(10);
     $string .= '<sourceTextLength>' . $src_lenght . '</sourceTextLength>' . chr(10);
     $string .= '<sourceTextContent>' . $src_feature_content . '</sourceTextContent>' . chr(10);
开发者ID:leloulight,项目名称:Cross-Language-Dataset,代码行数:31,代码来源:parse_PAN_collection.php

示例3: encode

 public static function encode($encodingLabel, $text)
 {
     $encodingLabel = self::normalizeEncoding($encodingLabel);
     if ($encodingLabel == 'UTF-8') {
         return Encoding::toUTF8($text);
     }
     if ($encodingLabel == 'ISO-8859-1') {
         return Encoding::toLatin1($text);
     }
 }
开发者ID:Geeklog-Plugins,项目名称:paypal,代码行数:10,代码来源:ForceUTF8.class.php

示例4: is

<?php

require_once "../autoload.php";
function is($desc, $a, $b)
{
    if ($a === $b) {
        echo '<span style="background-color: green;">&nbsp;Pass&nbsp;</span> ' . $desc . "<br/>\n";
    } else {
        echo '<span style="background-color: red;">&nbsp;Failed&nbsp;</span> ' . $desc . "<br/>\n";
    }
    return $a === $b;
}
$orig = "αšΓ‘šÑőαιν";
is("Encoding::toUTF8() convierte a UTF-8 todos los caracteres que no son ya UTF-8, teniendo en cuenta los que son Windows-1252, pero dejando sin cambios a los que ya son UTF-8", Encoding::toUTF8($orig), "ÑőњÑőÑéí");
$utf8_from_iso = "Β€ΒΒ‚ΒƒΒ„Β…Β†Β‡ΒˆΒ‰ΒŠΒ‹ΒŒΒΒŽΒΒΒ‘Β’Β“Β”Β•Β–Β—Β˜Β™ΒšΒ›ΒœΒΒžΒŸ";
$utf8_from_win = "β‚¬Ββ€šΖ’β€žβ€¦β€ β€‘Λ†β€°Ε β€ΉΕ’ΒΕ½ΒΒβ€˜β€™β€œβ€β€’β€“β€”Λœβ„’Ε‘β€ΊΕ“ΒΕΎΕΈ";
is("Encoding::UTF8FixWin1252Chars() convierte UTF-8 a UTF-8 corrigiendo caracteres especiales de Windows-1252", Encoding::UTF8FixWin1252Chars($utf8_from_iso), $utf8_from_win);
is("Encoding::toLatin1() convierte los UTF-8 a Windows-1252", Encoding::toLatin1($orig), "αšαšαšαιν");
is("Encoding::toLatin1() convierte los UTF-8 con caracteres convertidos desde Windows-1252 a Windows-1252", Encoding::toLatin1($utf8_from_win), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toLatin1() convierte los UTF-8 con caracteres convertidos desde ISO8859-1 a Windows-1252", Encoding::toLatin1($utf8_from_iso), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toWin1252() convierte los UTF-8 a Windows-1252", Encoding::toWin1252($orig), "αšαšαšαιν");
is("Encoding::toWin1252() convierte los UTF-8 con caracteres convertidos desde Windows-1252 a Windows-1252", Encoding::toWin1252($utf8_from_win), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::toWin1252() convierte los UTF-8 con caracteres convertidos desde ISO8859-1 a Windows-1252", Encoding::toWin1252($utf8_from_iso), "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ");
is("Encoding::fixUTF8() corrige UTF-8 convertido repetidamente", Encoding::fixUTF8(utf8_encode(utf8_encode(utf8_encode($orig)))), "ÑőÑőÑőÑéí");
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:24,代码来源:test.php

示例5: testEncodeToLatin1

 public function testEncodeToLatin1()
 {
     $latin1 = Encoding::toLatin1($this->utf8);
     $this->assertEquals($this->iso88591, $latin1);
 }
开发者ID:no-chris,项目名称:connector,代码行数:5,代码来源:EncodingTest.php


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