本文整理匯總了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 });
}
示例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);
}
示例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);
}
}
示例4: fn
crypto.subtle.decrypt(encryptAlgor, dekKey, dat).then((clear: ArrayBuffer) => {
em.message = textDecoder.decode(new Uint8Array(clear));
if (fn != null) {
fn();
}
})