xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/util_bytetochar.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1{{header}}
2{{object 1 0}} <<
3  /Type /Catalog
4  /Pages 2 0 R
5  /OpenAction 10 0 R
6>>
7endobj
8{{object 2 0}} <<
9  /Type /Pages
10  /Count 1
11  /Kids [
12    3 0 R
13  ]
14>>
15endobj
16% Page number 0.
17{{object 3 0}} <<
18  /Type /Page
19  /Parent 2 0 R
20  /Resources <<
21    /Font <</F1 15 0 R>>
22  >>
23  /Contents [21 0 R]
24  /MediaBox [0 0 612 792]
25>>
26endobj
27% OpenAction action
28{{object 10 0}} <<
29  /Type /Action
30  /S /JavaScript
31  /JS 11 0 R
32>>
33endobj
34% JS program to execute
35{{object 11 0}} <<
36  {{streamlen}}
37>>
38stream
39function TestOneInput(x) {
40  try {
41    var s = util.byteToChar(x);
42    if (s.length) {
43      s = s.charCodeAt(0);
44    }
45    app.alert(x + " => " + s);
46  }
47  catch (e) {
48    app.alert(x + ": Caught error: " + e);
49  }
50}
51TestOneInput(0);
52TestOneInput(65);
53TestOneInput(127);
54TestOneInput(128);
55TestOneInput(255);
56TestOneInput(256);
57TestOneInput(40000000);
58TestOneInput(-1);
59try {
60  util.byteToChar();
61}
62catch (e) {
63  app.alert("Caught expected error: " + e);
64}
65try {
66  util.byteToChar({x:39});
67}
68catch (e) {
69  app.alert("Caught expected error: " + e);
70}
71endstream
72endobj
73{{xref}}
74{{trailer}}
75{{startxref}}
76%%EOF
77