本文整理匯總了TypeScript中js-base64.Base64.encode方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Base64.encode方法的具體用法?TypeScript Base64.encode怎麽用?TypeScript Base64.encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類js-base64.Base64
的用法示例。
在下文中一共展示了Base64.encode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createHtml
function createHtml(svg: Buffer): string {
const html = `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src vscode-resource:; script-src vscode-resource:; img-src data:;">
<link href="${mediaPath('core.css')}" rel="stylesheet" type="text/css" media="all">
<link href="${mediaPath('button.css')}" rel="stylesheet" type="text/css" media="all">
<script src="${mediaPath('jquery-3.3.1.min.js')}"></script>
<script src="${mediaPath('export.js')}"></script>
</head>
<body>
<h1>Export Uiflow Diagram</h1>
<a id="export" href="#" class="btn">Export PNG</a>
<h1>Preview</h1>
<div id="img_cnt">
<h2>img</h2>
<img id="img" src="data:image/svg+xml;base64,${Base64.encode(svg.toString().replace(/\u0008/g, ''))}">
</div>
<div id="svg_cnt">
<h2>svg</h2>
${svg}
</div>
<div id="canvas_cnt">
<h2>canvas</h2>
<canvas></canvas>
</div>
</body>
</html>`;
return html;
}
示例2: Uint8ToBase64
/**
* thanks to
* https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string
*/
static Uint8ToBase64(data:Uint8Array):string{
let chunks = [];
let block = 0x8000;
for( let i = 0; i< data.length; i += block){
chunks.push( String.fromCharCode.apply(null, data.subarray(i, i + block)));
}
return Base64.encode(chunks.join(""));
}
示例3:
import { Base64 } from 'js-base64'
Base64.encode('dankogai'); // ZGFua29nYWk=
Base64.encode('小飼弾'); // 5bCP6aO85by+
Base64.encodeURI('小飼弾'); // 5bCP6aO85by-
Base64.decode('ZGFua29nYWk='); // dankogai
Base64.decode('5bCP6aO85by+'); // 小飼弾
// note .decodeURI() is unnecessary since it accepts both flavors
Base64.decode('5bCP6aO85by-'); // 小飼弾
示例4:
export const getGraphqlIdFromDBId = (id: string, schema: string): string =>
// This is temporary solution, we will use slugs in the future
Base64.encode(`${schema}:${id}`);
示例5:
import { Base64 } from 'js-base64';
Base64.encode(''); // $ExpectType string
Base64.encode('', true); // $ExpectType string
Base64.encodeURI(''); // $ExpectType string
Base64.decode(''); // $ExpectType string
Base64.atob(''); // $ExpectType string
Base64.btoa(''); // $ExpectType string
Base64.fromBase64(''); // $ExpectType string
Base64.toBase64(''); // $ExpectType string
Base64.toBase64('', true); // $ExpectType string
Base64.btou(''); // $ExpectType string
Base64.utob(''); // $ExpectType string
Base64.noConflict(); // $ExpectType typeof Base64
Base64.extendString(); // $ExpectType void
''.toBase64(); // $ExpectType string
''.toBase64(true); // $ExpectType string
''.toBase64URI(); // $ExpectType string
''.fromBase64(); // $ExpectType string
示例6: toBase64String
public static toBase64String(originalString: string): string {
return jsBase64.encode(originalString);
}