diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 2d58807..1cbb53f 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1384,11 +1384,30 @@ namespace OpenSim.Framework | |||
1384 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; | 1384 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | /// <summary> | ||
1388 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. | ||
1389 | /// </summary> | ||
1390 | /// <param name="str"> | ||
1391 | /// If null or empty, then an bytes[0] is returned. | ||
1392 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1393 | /// </param> | ||
1394 | /// <param name="args"> | ||
1395 | /// Arguments to substitute into the string via the {} mechanism. | ||
1396 | /// </param> | ||
1397 | /// <returns></returns> | ||
1387 | public static byte[] StringToBytes256(string str, params object[] args) | 1398 | public static byte[] StringToBytes256(string str, params object[] args) |
1388 | { | 1399 | { |
1389 | return StringToBytes256(string.Format(str, args)); | 1400 | return StringToBytes256(string.Format(str, args)); |
1390 | } | 1401 | } |
1391 | 1402 | ||
1403 | /// <summary> | ||
1404 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. | ||
1405 | /// </summary> | ||
1406 | /// <param name="str"> | ||
1407 | /// If null or empty, then an bytes[0] is returned. | ||
1408 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1409 | /// </param> | ||
1410 | /// <returns></returns> | ||
1392 | public static byte[] StringToBytes256(string str) | 1411 | public static byte[] StringToBytes256(string str) |
1393 | { | 1412 | { |
1394 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | 1413 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } |
@@ -1407,11 +1426,30 @@ namespace OpenSim.Framework | |||
1407 | return data; | 1426 | return data; |
1408 | } | 1427 | } |
1409 | 1428 | ||
1429 | /// <summary> | ||
1430 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 1024 bytes if necessary. | ||
1431 | /// </summary> | ||
1432 | /// <param name="str"> | ||
1433 | /// If null or empty, then an bytes[0] is returned. | ||
1434 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1435 | /// </param> | ||
1436 | /// <param name="args"> | ||
1437 | /// Arguments to substitute into the string via the {} mechanism. | ||
1438 | /// </param> | ||
1439 | /// <returns></returns> | ||
1410 | public static byte[] StringToBytes1024(string str, params object[] args) | 1440 | public static byte[] StringToBytes1024(string str, params object[] args) |
1411 | { | 1441 | { |
1412 | return StringToBytes1024(string.Format(str, args)); | 1442 | return StringToBytes1024(string.Format(str, args)); |
1413 | } | 1443 | } |
1414 | 1444 | ||
1445 | /// <summary> | ||
1446 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 1024 bytes if necessary. | ||
1447 | /// </summary> | ||
1448 | /// <param name="str"> | ||
1449 | /// If null or empty, then an bytes[0] is returned. | ||
1450 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1451 | /// </param> | ||
1452 | /// <returns></returns> | ||
1415 | public static byte[] StringToBytes1024(string str) | 1453 | public static byte[] StringToBytes1024(string str) |
1416 | { | 1454 | { |
1417 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | 1455 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } |