Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mcs/class/corlib/System/ChangeLog6
-rw-r--r--mcs/class/corlib/System/Convert.cs14
2 files changed, 20 insertions, 0 deletions
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog
index 7e5bd75fa4a..7299da851de 100644
--- a/mcs/class/corlib/System/ChangeLog
+++ b/mcs/class/corlib/System/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-30 Geoff Norton <gnorton@customerdna.com>
+
+ * Convert.cs: ConvertToBase* was not endian aware. Implemented EndianSwap
+ and swapping of all values before going into the BitConverter so that values
+ are returned with proper endianess.
+
2004-09-23 Martin Garton <martin@wrasse.demon.co.uk>
* Convert.cs: ToType was returning unconverted object when it should
diff --git a/mcs/class/corlib/System/Convert.cs b/mcs/class/corlib/System/Convert.cs
index 10e47a0bda3..a4651618ac1 100644
--- a/mcs/class/corlib/System/Convert.cs
+++ b/mcs/class/corlib/System/Convert.cs
@@ -2559,8 +2559,18 @@ namespace System {
return (long) result;
}
+ private static void EndianSwap (ref byte[] value)
+ {
+ byte[] buf = new byte[value.Length];
+ for (int i = 0; i < value.Length; i++)
+ buf[i] = value[value.Length-1-i];
+ value = buf;
+ }
+
private static string ConvertToBase2 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
byte b = value [i];
@@ -2580,6 +2590,8 @@ namespace System {
private static string ConvertToBase8 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
ulong l = 0;
switch (value.Length) {
case 1:
@@ -2612,6 +2624,8 @@ namespace System {
private static string ConvertToBase16 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
char high = (char)((value[i] >> 4) & 0x0f);