176
|
1 |
# $Id: NoUnicodeExt.pm,v 1.1 2002/01/30 17:35:21 matt Exp $
|
|
2 |
|
|
3 |
package XML::SAX::PurePerl;
|
|
4 |
use strict;
|
|
5 |
|
|
6 |
sub chr_ref {
|
|
7 |
my $n = shift;
|
|
8 |
if ($n < 0x80) {
|
|
9 |
return chr ($n);
|
|
10 |
}
|
|
11 |
elsif ($n < 0x800) {
|
|
12 |
return pack ("CC", (($n >> 6) | 0xc0), (($n & 0x3f) | 0x80));
|
|
13 |
}
|
|
14 |
elsif ($n < 0x10000) {
|
|
15 |
return pack ("CCC", (($n >> 12) | 0xe0), ((($n >> 6) & 0x3f) | 0x80),
|
|
16 |
(($n & 0x3f) | 0x80));
|
|
17 |
}
|
|
18 |
elsif ($n < 0x110000)
|
|
19 |
{
|
|
20 |
return pack ("CCCC", (($n >> 18) | 0xf0), ((($n >> 12) & 0x3f) | 0x80),
|
|
21 |
((($n >> 6) & 0x3f) | 0x80), (($n & 0x3f) | 0x80));
|
|
22 |
}
|
|
23 |
else {
|
|
24 |
return undef;
|
|
25 |
}
|
|
26 |
}
|
|
27 |
|
|
28 |
1;
|