File: writing-unicode.pl

package info (click to toggle)
libxml-writer-perl 0.900-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 2,609; makefile: 2
file content (18 lines) | stat: -rwxr-xr-x 321 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl -w

# Generate UTF-8 output of a Unicode string

use strict;

use XML::Writer;

my $unicodeString = "\x{201C}This\x{201D} is a test - \$ \x{00A3} \x{20AC}";

my $w = XML::Writer->new(ENCODING => 'utf-8');

$w->xmlDecl();

$w->startTag('doc');
$w->characters($unicodeString);
$w->endTag('doc');
$w->end();