Преглед изворни кода

fixing the issue of translating the non english language data

sadafk831 пре 5 година
родитељ
комит
bfbfdfcb96
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5
    3
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 5
- 3
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java Прегледај датотеку

@@ -514,11 +514,13 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
514 514
                             String utf8 = new String(b);
515 515
                             callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
516 516
                         }
517
-                        // This usually mean the data is contains invalid unicode characters, it's
518
-                        // binary data
517
+                        // This usually mean the data is contains invalid unicode characters but still valid data,
518
+                        // it's binary data, so send it as a normal string
519 519
                         catch(CharacterCodingException ignored) {
520
+                            
520 521
                             if(responseFormat == ResponseFormat.UTF8) {
521
-                                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, "");
522
+                                String utf8 = new String(b);
523
+                                callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_UTF8, utf8);
522 524
                             }
523 525
                             else {
524 526
                                 callback.invoke(null, RNFetchBlobConst.RNFB_RESPONSE_BASE64, android.util.Base64.encodeToString(b, Base64.NO_WRAP));