File: escape1.t

package info (click to toggle)
libmarc-charset-perl 0.95-1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 2,444 kB
  • ctags: 75
  • sloc: xml: 98,939; perl: 612; makefile: 52
file content (74 lines) | stat: -rw-r--r-- 2,524 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use Test::More tests => 3;

## this test will exercise the first type of character escapes 
## as documents at http://lcweb.loc.gov/marc/specifications/speccharmarc8.html
## Technique 1: Greek Symbols, Subscript, and Superscript Characters

use strict;
use MARC::Charset qw(marc8_to_utf8);
use MARC::Charset::Constants qw(:all);

## Greek Symbols

my $test = 
    'it is all greek ' . 
    ESCAPE . GREEK_SYMBOLS .                  ## escape to Greek Symbols
    chr(0x61) . chr(0x62) . chr(0x63) .       ## ALPHA BETA GAMMA
    ESCAPE . ASCII_DEFAULT.                   ## back to ASCII
    ' to me';

my $expected = 
    'it is all greek ' .
    # ucs chr(0xCEB1) . chr(0xCEB2) . chr(0xCEB3) .
    chr(0x03B1) . chr(0x03B2) . chr(0x03B3) .
    ' to me';

is( marc8_to_utf8($test), $expected, 'Greek Symbols' );

## Subscripts

$test = 
    'subscript1' .                    
    ESCAPE . SUBSCRIPTS .                  ## escape to Subscripts 
    chr(0x31) .                            ## subscript 1
    ESCAPE . ASCII_DEFAULT .               ## back to ASCII
    'subscript9' .            
    ESCAPE . SUBSCRIPTS .                  ## escape to Subscripts
    chr(0x39) .                            ## subscript 9
    ESCAPE . ASCII_DEFAULT .               ## back to ASCII
    'subscript10' . 
    ESCAPE . SUBSCRIPTS .                  ## back to Subscripts again
    chr(0x31) . chr(0x30) .                ## subscript 10
    ESCAPE . ASCII_DEFAULT;                ## back to ASCII

$expected = 
    'subscript1' . chr(0x2081) . 
    'subscript9' . chr(0x2089) . 
    'subscript10' . chr(0x2081) . chr(0x2080); 

is( marc8_to_utf8($test), $expected, 'Subscripts' );


## Superscripts

$test =
    'superscript1' . 
    ESCAPE . SUPERSCRIPTS .                    ## escape to Superscripts
    chr(0x31) .                                ## superscript 1
    ESCAPE . ASCII_DEFAULT .                   ## back to ASCII
    'superscript9' . 
    ESCAPE . SUPERSCRIPTS .                    ## escape to Superscripts
    chr(0x39) .                                ## superscript 9
    ESCAPE . ASCII_DEFAULT .                   ## back to ASCII
    'superscript10' .
    ESCAPE . SUPERSCRIPTS . 
    chr(0x31) . chr(0x30) .                    ## superscript 10
    ESCAPE . ASCII_DEFAULT;                    ## back to ASCII

$expected = 
    'superscript1' . chr(0x00B9) . 
    'superscript9' . chr(0x2079) . 
    'superscript10' . chr(0x00B9) . chr(0x2070); 

is( marc8_to_utf8($test), $expected, 'Superscripts' );