Skip to content

Commit ff2a650

Browse files
committed
fix:修复readFile方法读取文件以ascii码返回结果是buffer而不是数组的问题
1 parent 61f7188 commit ff2a650

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

harmony/blobUtil/src/main/ets/ReactNativeBlobUtil/ReactNativeBlobUtilFS.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,16 @@ export default class ReactNativeBlobUtilFS {
354354
} else {
355355
let bytes = buffer.from(buf, 0, readLen);
356356
switch (encoding.toLowerCase()) {
357-
case "base64":
357+
case 'base64':
358358
resolve(bytes.toString('base64'));
359359
break;
360-
case "ascii":
361-
resolve(buffer.transcode(bytes, 'utf-8', 'ascii'));
360+
case 'ascii': {
361+
let ascUInt8Array: Uint8Array = new Uint8Array(bytes.buffer);
362+
let ascArr = Array.from(ascUInt8Array);
363+
resolve(ascArr);
362364
break;
363-
case "utf8":
365+
}
366+
case 'utf8':
364367
resolve(bytes.toString('utf-8'));
365368
break;
366369
default:

0 commit comments

Comments
 (0)