增加Res 类

This commit is contained in:
DevWiki 2024-07-05 14:27:49 +08:00
parent c0c8d90c4f
commit 0cfbbb8065

View File

@ -0,0 +1,18 @@
import { util } from '@kit.ArkTS';
export class Res {
static getRawFileContent(name: string): string {
let content = getContext().resourceManager.getRawFileContentSync(name);
let textDecoderOptions: util.TextDecoderOptions = {
fatal: false,
ignoreBOM : true
}
let decodeWithStreamOptions: util.DecodeWithStreamOptions = {
stream: true
}
let textDecoder = util.TextDecoder.create('utf-8', textDecoderOptions);
let retStr = textDecoder.decodeWithStream( content , decodeWithStreamOptions);
return retStr;
}
}