1--TEST--
2Test base64_encode() function : basic functionality
3--FILE--
4<?php
5/*
6 * Test base64_encode with single byte values.
7 */
8
9echo "*** Testing base64_encode() : basic functionality ***\n";
10
11for ($i=0; $i<256; $i++) {
12    $str = pack("c", $i);
13    $enc = base64_encode($str);
14    printf("0x%X: %s\n", $i, $enc);
15}
16
17$values = array(
18    "Hello World",
19    "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]",
20    "\n\t Line with control characters\r\n",
21    "\xC1\xC2\xC3\xC4\xC5\xC6",
22    "\75\76\77\78\79\80",
23    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!",
24    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!\75\76\77\78\79\80",
25    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!",
26    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%!\75\76\77\78\79\80"
27);
28
29foreach($values as $str) {
30    $enc = base64_encode($str);
31    printf("%s\n", $enc);
32}
33
34echo "Done\n";
35?>
36--EXPECT--
37*** Testing base64_encode() : basic functionality ***
380x0: AA==
390x1: AQ==
400x2: Ag==
410x3: Aw==
420x4: BA==
430x5: BQ==
440x6: Bg==
450x7: Bw==
460x8: CA==
470x9: CQ==
480xA: Cg==
490xB: Cw==
500xC: DA==
510xD: DQ==
520xE: Dg==
530xF: Dw==
540x10: EA==
550x11: EQ==
560x12: Eg==
570x13: Ew==
580x14: FA==
590x15: FQ==
600x16: Fg==
610x17: Fw==
620x18: GA==
630x19: GQ==
640x1A: Gg==
650x1B: Gw==
660x1C: HA==
670x1D: HQ==
680x1E: Hg==
690x1F: Hw==
700x20: IA==
710x21: IQ==
720x22: Ig==
730x23: Iw==
740x24: JA==
750x25: JQ==
760x26: Jg==
770x27: Jw==
780x28: KA==
790x29: KQ==
800x2A: Kg==
810x2B: Kw==
820x2C: LA==
830x2D: LQ==
840x2E: Lg==
850x2F: Lw==
860x30: MA==
870x31: MQ==
880x32: Mg==
890x33: Mw==
900x34: NA==
910x35: NQ==
920x36: Ng==
930x37: Nw==
940x38: OA==
950x39: OQ==
960x3A: Og==
970x3B: Ow==
980x3C: PA==
990x3D: PQ==
1000x3E: Pg==
1010x3F: Pw==
1020x40: QA==
1030x41: QQ==
1040x42: Qg==
1050x43: Qw==
1060x44: RA==
1070x45: RQ==
1080x46: Rg==
1090x47: Rw==
1100x48: SA==
1110x49: SQ==
1120x4A: Sg==
1130x4B: Sw==
1140x4C: TA==
1150x4D: TQ==
1160x4E: Tg==
1170x4F: Tw==
1180x50: UA==
1190x51: UQ==
1200x52: Ug==
1210x53: Uw==
1220x54: VA==
1230x55: VQ==
1240x56: Vg==
1250x57: Vw==
1260x58: WA==
1270x59: WQ==
1280x5A: Wg==
1290x5B: Ww==
1300x5C: XA==
1310x5D: XQ==
1320x5E: Xg==
1330x5F: Xw==
1340x60: YA==
1350x61: YQ==
1360x62: Yg==
1370x63: Yw==
1380x64: ZA==
1390x65: ZQ==
1400x66: Zg==
1410x67: Zw==
1420x68: aA==
1430x69: aQ==
1440x6A: ag==
1450x6B: aw==
1460x6C: bA==
1470x6D: bQ==
1480x6E: bg==
1490x6F: bw==
1500x70: cA==
1510x71: cQ==
1520x72: cg==
1530x73: cw==
1540x74: dA==
1550x75: dQ==
1560x76: dg==
1570x77: dw==
1580x78: eA==
1590x79: eQ==
1600x7A: eg==
1610x7B: ew==
1620x7C: fA==
1630x7D: fQ==
1640x7E: fg==
1650x7F: fw==
1660x80: gA==
1670x81: gQ==
1680x82: gg==
1690x83: gw==
1700x84: hA==
1710x85: hQ==
1720x86: hg==
1730x87: hw==
1740x88: iA==
1750x89: iQ==
1760x8A: ig==
1770x8B: iw==
1780x8C: jA==
1790x8D: jQ==
1800x8E: jg==
1810x8F: jw==
1820x90: kA==
1830x91: kQ==
1840x92: kg==
1850x93: kw==
1860x94: lA==
1870x95: lQ==
1880x96: lg==
1890x97: lw==
1900x98: mA==
1910x99: mQ==
1920x9A: mg==
1930x9B: mw==
1940x9C: nA==
1950x9D: nQ==
1960x9E: ng==
1970x9F: nw==
1980xA0: oA==
1990xA1: oQ==
2000xA2: og==
2010xA3: ow==
2020xA4: pA==
2030xA5: pQ==
2040xA6: pg==
2050xA7: pw==
2060xA8: qA==
2070xA9: qQ==
2080xAA: qg==
2090xAB: qw==
2100xAC: rA==
2110xAD: rQ==
2120xAE: rg==
2130xAF: rw==
2140xB0: sA==
2150xB1: sQ==
2160xB2: sg==
2170xB3: sw==
2180xB4: tA==
2190xB5: tQ==
2200xB6: tg==
2210xB7: tw==
2220xB8: uA==
2230xB9: uQ==
2240xBA: ug==
2250xBB: uw==
2260xBC: vA==
2270xBD: vQ==
2280xBE: vg==
2290xBF: vw==
2300xC0: wA==
2310xC1: wQ==
2320xC2: wg==
2330xC3: ww==
2340xC4: xA==
2350xC5: xQ==
2360xC6: xg==
2370xC7: xw==
2380xC8: yA==
2390xC9: yQ==
2400xCA: yg==
2410xCB: yw==
2420xCC: zA==
2430xCD: zQ==
2440xCE: zg==
2450xCF: zw==
2460xD0: 0A==
2470xD1: 0Q==
2480xD2: 0g==
2490xD3: 0w==
2500xD4: 1A==
2510xD5: 1Q==
2520xD6: 1g==
2530xD7: 1w==
2540xD8: 2A==
2550xD9: 2Q==
2560xDA: 2g==
2570xDB: 2w==
2580xDC: 3A==
2590xDD: 3Q==
2600xDE: 3g==
2610xDF: 3w==
2620xE0: 4A==
2630xE1: 4Q==
2640xE2: 4g==
2650xE3: 4w==
2660xE4: 5A==
2670xE5: 5Q==
2680xE6: 5g==
2690xE7: 5w==
2700xE8: 6A==
2710xE9: 6Q==
2720xEA: 6g==
2730xEB: 6w==
2740xEC: 7A==
2750xED: 7Q==
2760xEE: 7g==
2770xEF: 7w==
2780xF0: 8A==
2790xF1: 8Q==
2800xF2: 8g==
2810xF3: 8w==
2820xF4: 9A==
2830xF5: 9Q==
2840xF6: 9g==
2850xF7: 9w==
2860xF8: +A==
2870xF9: +Q==
2880xFA: +g==
2890xFB: +w==
2900xFC: /A==
2910xFD: /Q==
2920xFE: /g==
2930xFF: /w==
294SGVsbG8gV29ybGQ=
295QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3ODkwISVeJiooKXt9W10=
296CgkgTGluZSB3aXRoIGNvbnRyb2wgY2hhcmFjdGVycw0K
297wcLDxMXG
298PT4/BzgHOVw4MA==
299QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIQ==
300QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIT0+Pwc4BzlcODA=
301QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE=
302QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODklIUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5JSE9Pj8HOAc5XDgw
303Done
304