本文整理汇总了TypeScript中text-encoding.TextDecoder.decode方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextDecoder.decode方法的具体用法?TypeScript TextDecoder.decode怎么用?TypeScript TextDecoder.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text-encoding.TextDecoder
的用法示例。
在下文中一共展示了TextDecoder.decode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
}
}
示例2: 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 });
}
示例3: Uint8Array
crypto.subtle.decrypt(encryptAlgor, dekKey, dat).then((clear: ArrayBuffer) => {
em.message = textDecoder.decode(new Uint8Array(clear));
if (fn != null) {
fn();
}
})
示例4: 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);
}