@magic-xpa/utils 4.1000.0-dev4100.7 → 4.1000.0-dev4100.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1462,16 +1462,11 @@ class Misc {
|
|
|
1462
1462
|
}
|
|
1463
1463
|
|
|
1464
1464
|
class Base64 {
|
|
1465
|
-
static encode(
|
|
1466
|
-
if (arguments.length ===
|
|
1467
|
-
return Base64.
|
|
1468
|
-
else if (arguments.length === 3)
|
|
1469
|
-
return Base64.encode_1(strOrData, encodingOrIsUseEnvCharset, encoding);
|
|
1465
|
+
static encode(str, isUseEnvCharset, encoding) {
|
|
1466
|
+
if (arguments.length === 1)
|
|
1467
|
+
return Base64.encode_1(str, false, null);
|
|
1470
1468
|
else
|
|
1471
|
-
return Base64.
|
|
1472
|
-
}
|
|
1473
|
-
static encode_0(str, encoding) {
|
|
1474
|
-
return Base64.encode(str, false, encoding);
|
|
1469
|
+
return Base64.encode_1(str, isUseEnvCharset, encoding);
|
|
1475
1470
|
}
|
|
1476
1471
|
static encode_1(str, isUseEnvCharset, encoding) {
|
|
1477
1472
|
let result;
|
|
@@ -1484,10 +1479,15 @@ class Base64 {
|
|
|
1484
1479
|
}
|
|
1485
1480
|
else {
|
|
1486
1481
|
try {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1482
|
+
if (isUseEnvCharset === false) {
|
|
1483
|
+
result = btoa(str);
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
let instance = ISO_8859_1_Encoding.ISO_8859_1;
|
|
1487
|
+
let encoding2 = isUseEnvCharset ? encoding : instance;
|
|
1488
|
+
let ba = Base64.encodeBytes(encoding2.GetBytes(str));
|
|
1489
|
+
result = instance.GetString(ba, 0, ba.length);
|
|
1490
|
+
}
|
|
1491
1491
|
}
|
|
1492
1492
|
catch (ex) {
|
|
1493
1493
|
throw new ApplicationException(ex.Message);
|
|
@@ -1496,7 +1496,7 @@ class Base64 {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
return result;
|
|
1498
1498
|
}
|
|
1499
|
-
static
|
|
1499
|
+
static encodeBytes(data) {
|
|
1500
1500
|
if (data === null)
|
|
1501
1501
|
return null;
|
|
1502
1502
|
let dest = new Uint8Array(Math.floor((data.length + 2) / 3) * 4);
|
|
@@ -1525,16 +1525,10 @@ class Base64 {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
return dest;
|
|
1527
1527
|
}
|
|
1528
|
-
static decode(
|
|
1529
|
-
if (arguments.length === 1
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
return Base64.decode_1(strOrData, encoding);
|
|
1533
|
-
else
|
|
1534
|
-
return Base64.decode_2(strOrData);
|
|
1535
|
-
}
|
|
1536
|
-
static decode_0(str) {
|
|
1537
|
-
return Base64.decode(str, null);
|
|
1528
|
+
static decode(str, encoding) {
|
|
1529
|
+
if (arguments.length === 1)
|
|
1530
|
+
encoding = null;
|
|
1531
|
+
return Base64.decode_1(str, encoding);
|
|
1538
1532
|
}
|
|
1539
1533
|
static decode_1(str, encoding) {
|
|
1540
1534
|
let result;
|
|
@@ -1547,10 +1541,15 @@ class Base64 {
|
|
|
1547
1541
|
}
|
|
1548
1542
|
else {
|
|
1549
1543
|
try {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1544
|
+
if (encoding === null || encoding === undefined) {
|
|
1545
|
+
result = atob(str);
|
|
1546
|
+
}
|
|
1547
|
+
else {
|
|
1548
|
+
let instance = ISO_8859_1_Encoding.ISO_8859_1;
|
|
1549
|
+
let array = Base64.decodeBytes(instance.GetBytes(str));
|
|
1550
|
+
let encoding2 = (encoding !== null) ? encoding : instance;
|
|
1551
|
+
result = encoding2.GetString(array, 0, array.length);
|
|
1552
|
+
}
|
|
1554
1553
|
}
|
|
1555
1554
|
catch (ex) {
|
|
1556
1555
|
throw new ApplicationException(ex.Message);
|
|
@@ -1559,7 +1558,7 @@ class Base64 {
|
|
|
1559
1558
|
}
|
|
1560
1559
|
return result;
|
|
1561
1560
|
}
|
|
1562
|
-
static
|
|
1561
|
+
static decodeBytes(data) {
|
|
1563
1562
|
if (data === null)
|
|
1564
1563
|
return null;
|
|
1565
1564
|
let tail = data.length;
|
|
@@ -1598,7 +1597,7 @@ class Base64 {
|
|
|
1598
1597
|
return new Uint8Array(0);
|
|
1599
1598
|
try {
|
|
1600
1599
|
let instance = ISO_8859_1_Encoding.ISO_8859_1;
|
|
1601
|
-
return Base64.
|
|
1600
|
+
return Base64.decodeBytes(instance.GetBytes(str));
|
|
1602
1601
|
}
|
|
1603
1602
|
catch (ex) {
|
|
1604
1603
|
throw new ApplicationException(ex.Message);
|