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


PHP Twig_Environment::setCharset方法代码示例

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


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

示例1: testReverseFilterOnNonUTF8String

 public function testReverseFilterOnNonUTF8String()
 {
     $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
     $twig->setCharset('ISO-8859-1');
     $input = iconv('UTF-8', 'ISO-8859-1', 'Äé');
     $output = iconv('ISO-8859-1', 'UTF-8', twig_reverse_filter($twig, $input));
     $this->assertEquals($output, 'éÄ');
 }
开发者ID:PieterSwitten,项目名称:webandmobile,代码行数:8,代码来源:CoreTest.php

示例2: testReverseFilterOnNonUTF8String

 public function testReverseFilterOnNonUTF8String()
 {
     if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) {
         $this->markTestSkipped('needs iconv or mbstring');
     }
     $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'));
     $twig->setCharset('ISO-8859-1');
     $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
     $output = twig_convert_encoding(twig_reverse_filter($twig, $input), 'UTF-8', 'ISO-8859-1');
     $this->assertEquals($output, 'éÄ');
 }
开发者ID:Aryellix,项目名称:scrumator,代码行数:11,代码来源:CoreTest.php

示例3: getLoader

        return $context;
    }
    class myRenderer extends sfTemplateRendererTwig
    {
        public function getLoader()
        {
            return $this->loader;
        }
        public function getEnvironment()
        {
            return $this->environment;
        }
    }
}
$t = new lime_test();
$t->diag('->__construct()');
$renderer = new myRenderer();
$t->is(get_class($renderer->getLoader()), 'Twig_Loader_String', '->__construct() creates an instance of "Twig_Loader_String" automatically');
$t->is($renderer->getEnvironment()->getCharset(), 'UTF-8', '->__construct() creates an instance of "Twig_Environment" automatically');
$loader = new Twig_Loader_Filesystem('./');
$environment = new Twig_Environment($loader);
$environment->setCharset('Shift_JIS');
$renderer = new myRenderer($loader, $environment);
$t->is(get_class($renderer->getLoader()), 'Twig_Loader_Filesystem', '->__construct() uses the specified instance of "Twig_Loader_Filesystem"');
$t->is($renderer->getEnvironment()->getCharset(), 'Shift_JIS', '->__construct() uses the specified instance of "Twig_Environment"');
$t->diag('->evaluate()');
$fixtureDir = realpath(dirname(__FILE__) . '/../fixtures');
$renderer = new sfTemplateRendererTwig();
$t->is($renderer->evaluate(new sfTemplateStorageString('Kousuke')), 'Kousuke', '->evaluate() returns string from the sfTemplateStorageString');
$t->is($renderer->evaluate(new sfTemplateStorageFile($fixtureDir . '/template/twig.tpl')), file_get_contents($fixtureDir . '/template/twig.tpl'), '->evaluate() returns string from the sfTemplateStorageFile');
$t->is($renderer->evaluate(new sfTemplateStorageString('{{ name }}'), array('name' => 'Ebihara')), 'Ebihara', '->evaluate() returns string from the sfTemplateStorageString and the parameters');
开发者ID:te-koyama,项目名称:openpne,代码行数:31,代码来源:sfTemplateRendererTwigTest.php


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