File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 37
37
o2 = data . charCodeAt ( i ++ ) ;
38
38
o3 = data . charCodeAt ( i ++ ) ;
39
39
40
- if ( o1 > 128 || o2 > 128 || o3 > 128 ) {
40
+ if ( o1 > 255 || o2 > 255 || o3 > 255 ) {
41
41
throw new InvalidCharacterError ( "'btoa' failed: The string to be encoded contains characters outside of the Latin1 range." ) ;
42
42
}
43
43
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ describe ('Base64.js', function() {
29
29
assert . strictEqual ( btoa ( 'qrstuvwxyz{|}~' ) , 'cXJzdHV2d3h5ent8fX4=' ) ;
30
30
} ) ;
31
31
32
- it ( 'cannot encode non-ASCII input' , function ( ) {
32
+ it ( 'cannot encode characters beyond U+00FF' , function ( ) {
33
+ assert . strictEqual ( String . fromCharCode ( 0x2708 ) , '✈' ) ;
33
34
assert . throws (
34
35
function ( ) { btoa ( '✈' ) ; } ,
35
36
function ( err ) {
@@ -83,4 +84,11 @@ describe ('Base64.js', function() {
83
84
assert . strictEqual ( atob ( null ) , atob ( 'null' ) ) ;
84
85
} ) ;
85
86
87
+ it ( 'can encode every character in [U+0000, U+00FF]' , function ( ) {
88
+ for ( var code = 0x0 ; code <= 0xFF ; code += 0x1 ) {
89
+ var char = String . fromCharCode ( code ) ;
90
+ assert . strictEqual ( atob ( btoa ( char ) ) , char ) ;
91
+ }
92
+ } ) ;
93
+
86
94
} ) ;
You can’t perform that action at this time.
0 commit comments