本文整理汇总了TypeScript中text-encoding.TextDecoder类的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDecoder类的具体用法?TypeScript TextDecoder怎么用?TypeScript TextDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextDecoder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test_decoder
function test_decoder() {
var text = "plain text";
var uint8array: Uint8Array = TextEncoder().encode(text);
var arrayBuffer: ArrayBuffer = uint8array.buffer;
// constructor
text = new TextDecoder().decode(uint8array);
text = new TextDecoder("utf-8").decode(uint8array);
text = new TextDecoder("windows-1252", {}).decode(uint8array);
text = new TextDecoder("windows-1252", { fatal: true }).decode(uint8array);
text = new TextDecoder("windows-1252", { ignoreBOM: true }).decode(
uint8array
);
text = TextDecoder().decode(uint8array);
text = TextDecoder("utf-8").decode(uint8array);
text = TextDecoder("windows-1252", {}).decode(uint8array);
text = TextDecoder("windows-1252", { fatal: true }).decode(uint8array);
text = TextDecoder("windows-1252", { ignoreBOM: true }).decode(uint8array);
// attributes
var decoder = new TextDecoder();
var encoding: string = decoder.encoding;
var fatal: boolean = decoder.fatal;
var ignoreBOM: boolean = decoder.ignoreBOM;
// methods
decoder.decode();
decoder.decode(uint8array);
decoder.decode(arrayBuffer);
decoder.decode(uint8array, { stream: true });
}
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:35,代码来源:text-encoding-tests.ts
示例2: reject
(err, paypro) => {
if (!disableLoader) this.onGoingProcessProvider.clear();
if (_.isArrayBuffer(err)) {
const enc = new encoding.TextDecoder();
err = enc.decode(err);
return reject(err);
} else if (err)
return reject(
this.translate.instant(
'Could Not Fetch Payment: Check if it is still valid'
)
);
else if (!paypro.verified) {
this.logger.warn('Failed to verify payment protocol signatures');
return reject(this.translate.instant('Payment Protocol Invalid'));
}
return resolve(paypro);
}
开发者ID:cmgustavo,项目名称:copay,代码行数:18,代码来源:paypro.ts
示例3: decode
export function decode(binary : Uint8Array, start = 0, end = binary.length) {
if(start !== 0 || end !== binary.length){
return decoder.decode(binary.subarray(start, end));
}else{
return decoder.decode(binary);
}
}
开发者ID:strangesast,项目名称:es-git,代码行数:7,代码来源:utils.ts
示例4: fn
crypto.subtle.decrypt(encryptAlgor, dekKey, dat).then((clear: ArrayBuffer) => {
em.message = textDecoder.decode(new Uint8Array(clear));
if (fn != null) {
fn();
}
})
开发者ID:ebekker,项目名称:keypear,代码行数:7,代码来源:kp-crypto.ts
注:本文中的text-encoding.TextDecoder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论