File: unicode-nbsp.t

package info (click to toggle)
libhtml-tidy-perl 1.60-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 1,289; sh: 23; makefile: 7
file content (23 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!perl -T

use warnings;
use strict;

use Test::More tests => 3;

use HTML::Tidy;

use Encode;

my $bytes_string = "\x{c2}\x{a0}"; #UTF8 nbsp
my $perl_chars   = Encode::decode('utf8',$bytes_string); # Perl chars of utf8 byte string

my $tidy = HTML::Tidy->new({ show_body_only => 1 });

my $newline = $tidy->clean( '' ); # HTML::Tidy adds a platform-dependent "newline".
like( $newline, qr/^\r?\n?$/, 'Tidy Newline' ); # should be CR or LF or both

my $expected_after_tidy = " $newline"; # HTML::Tidy should convert the nbsp to an HTML entity (and add a newline).

is( $tidy->clean( $perl_chars ), $expected_after_tidy, 'Perl chars OK' );
is( $tidy->clean( $bytes_string ), $expected_after_tidy, 'Byte string OK' );