@@ -503,28 +503,12 @@ private void done(Response resp) {
503503 // encoding will somehow break the UTF8 string format, to encode UTF8
504504 // string correctly, we should do URL encoding before BASE64.
505505 byte [] b = resp .body ().bytes ();
506- CharsetEncoder encoder = Charset .forName ("UTF-8" ).newEncoder ();
507506 if (responseFormat == ResponseFormat .BASE64 ) {
508507 callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_BASE64 , android .util .Base64 .encodeToString (b , Base64 .NO_WRAP ));
509508 return ;
510509 }
511- try {
512- encoder .encode (ByteBuffer .wrap (b ).asCharBuffer ());
513- // if the data contains invalid characters the following lines will be
514- // skipped.
515- String utf8 = new String (b );
516- callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_UTF8 , utf8 );
517- }
518- // This usually mean the data is contains invalid unicode characters, it's
519- // binary data
520- catch (CharacterCodingException ignored ) {
521- if (responseFormat == ResponseFormat .UTF8 ) {
522- callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_UTF8 , "" );
523- }
524- else {
525- callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_BASE64 , android .util .Base64 .encodeToString (b , Base64 .NO_WRAP ));
526- }
527- }
510+ String utf8 = new String (b );
511+ callback .invoke (null , RNFetchBlobConst .RNFB_RESPONSE_UTF8 , utf8 );
528512 }
529513 } catch (IOException e ) {
530514 callback .invoke ("RNFetchBlob failed to encode response data to BASE64 string." , null );
0 commit comments