Text-VimColor

 view release on metacpan or  search on metacpan

t/encoding.t  view on Meta::CPAN

ok Encode::is_utf8($html), 'expected output has wide characters';

# some of these use cases were taken from actual code in other CPAN modules.
# we'll test their usage here to ensure we don't break anything

env_compare [qw(utf8 c)] => 'ascii is fine',
  sub { string("( hi )\n") }, tvc_html('hi');

# FIXME: These don't work on a lot of smokers (particularly FreeBSD),
# (even ones with vim 7.2 +multi_byte).
# We could do a simple check to see if BOM recognition works as we expect it
# and only then perform this test, because really we only want to test that
# we haven't broken this functionality in environments where it already worked.
# Aside from lots of failing reports, see also rt-92601.

TODO: {

  local $TODO = 'Do simpler pre-tests to determine if these tests should pass in this evironment.';

env_compare utf8 => 'use BOM to get vim to honor encoded text',
  sub { prepend_bom($filetype, $input) }, $html;

env_compare utf8 => 'specify encoding by adding "+set fenc=..." to vim_options',
  sub { pass_vim_options(undef, $input, {filetype => $filetype}) }, $html;

}

env_compare [qw(utf8 c)] => 'detect utf8 string and use utf-8 automatically',
  sub { string($utf8) }, $html;

t/encoding.t  view on Meta::CPAN

  return $html;
}
# code from other modules copied verbatim

sub prepend_bom {
  my ($lang, $str) = @_;
  # MORITZ/App-Mowyw-v0.7.1/lib/App/Mowyw.pm#L566
  {
    # any encoding will do if vim automatically detects it
    my $vim_encoding = 'utf-8';
    my $BOM = "\x{feff}";
    my $syn = Text::VimColor->new(
            filetype    => $lang,
            string      => encode($vim_encoding, $BOM . $str),
            );
    $str = decode($vim_encoding, $syn->html);
    $str =~ s/^$BOM//;
    return $str;
  };
}

sub pass_vim_options {
  # RJBS/Pod-Elemental-Transfomer-VimHTML-0.093581/lib/Pod/Elemental/Transformer/VimHTML.pm#L15
  {
    my ($self, $str, $param) = @_;

    my $octets = Encode::encode('utf-8', $str, Encode::FB_CROAK);



( run in 0.250 second using v1.01-cache-2.11-cpan-131fc08a04b )