diff --git a/common_ui/src/main/ets/utils/Res.ets b/common_ui/src/main/ets/utils/Res.ets new file mode 100644 index 0000000..e3a6806 --- /dev/null +++ b/common_ui/src/main/ets/utils/Res.ets @@ -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; + } +} \ No newline at end of file