mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-07-24 20:35:42 +00:00
Move in ui-qr as react-qr (from apps) (#164)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2019 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export function encodeNumber (value: number): Uint8Array {
|
||||
return new Uint8Array([value >> 8, value & 256]);
|
||||
}
|
||||
|
||||
export function encodeString (value: string): Uint8Array {
|
||||
const u8a = new Uint8Array(value.length);
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
u8a[i] = value.charCodeAt(i);
|
||||
}
|
||||
|
||||
return u8a;
|
||||
}
|
||||
|
||||
export function decodeString (value: Uint8Array): string {
|
||||
return value.reduce((str, code): string => {
|
||||
return str + String.fromCharCode(code);
|
||||
}, '');
|
||||
}
|
||||
Reference in New Issue
Block a user