增加Res 类
This commit is contained in:
parent
c0c8d90c4f
commit
0cfbbb8065
18
common_ui/src/main/ets/utils/Res.ets
Normal file
18
common_ui/src/main/ets/utils/Res.ets
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user