Revision control
Copy as Markdown
import QtQuick 2.0
QtObject {
property string test1: Qt.btoa()
property string test2: Qt.btoa("Hello world!")
property string test3: Qt.btoa(['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!'])
property var better: Qt.btoa([
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01,
0x00, 0x01, 0x00, 0xF0, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3B
]);
property var better2: Qt.btoa(new Uint8Array([
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01,
0x00, 0x01, 0x00, 0xF0, 0x00, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3B
]).buffer)
function bad1() {
return Qt.btoa([999, 888]);
}
function bad2() {
return Qt.btoa(['ab', 'cde']);
}
function bad3() {
return Qt.btoa([this]);
}
}