From 0cfbbb80653cf92eb17aa8646a92f1451759817e Mon Sep 17 00:00:00 2001 From: DevWiki Date: Fri, 5 Jul 2024 14:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Res=20=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common_ui/src/main/ets/utils/Res.ets | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 common_ui/src/main/ets/utils/Res.ets 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