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:
authorMikko Korkalo <mikko@korkalo.fi>2013-02-11 02:48:36 +0400
committerMikko Korkalo <mikko@korkalo.fi>2013-02-11 03:48:53 +0400
commit77eb88801ec55bbdb769c4d3b14b8cb39fad2a5f (patch)
treef0d7a26c647e4a78ecc63a8e4d7853de8c83aa9a /mcs/class/I18N/Rare
parentac42aaea2e92e475bce342cae84ef0d90ec4294f (diff)
regenerated encoder classes with a patched ucm2cp.c with proper EncoderFallback support
Diffstat (limited to 'mcs/class/I18N/Rare')
-rw-r--r--mcs/class/I18N/Rare/CP1026.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1047.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1140.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1141.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1142.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1143.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1144.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1145.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1146.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1147.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1148.cs72
-rw-r--r--mcs/class/I18N/Rare/CP1149.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20273.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20277.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20278.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20280.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20284.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20285.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20290.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20297.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20420.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20424.cs72
-rw-r--r--mcs/class/I18N/Rare/CP20871.cs72
-rw-r--r--mcs/class/I18N/Rare/CP21025.cs72
-rw-r--r--mcs/class/I18N/Rare/CP37.cs72
-rw-r--r--mcs/class/I18N/Rare/CP500.cs72
-rw-r--r--mcs/class/I18N/Rare/CP708.cs81
-rw-r--r--mcs/class/I18N/Rare/CP852.cs81
-rw-r--r--mcs/class/I18N/Rare/CP855.cs81
-rw-r--r--mcs/class/I18N/Rare/CP857.cs81
-rw-r--r--mcs/class/I18N/Rare/CP858.cs81
-rw-r--r--mcs/class/I18N/Rare/CP862.cs81
-rw-r--r--mcs/class/I18N/Rare/CP864.cs81
-rw-r--r--mcs/class/I18N/Rare/CP866.cs81
-rw-r--r--mcs/class/I18N/Rare/CP869.cs81
-rw-r--r--mcs/class/I18N/Rare/CP870.cs72
-rw-r--r--mcs/class/I18N/Rare/CP875.cs72
37 files changed, 2523 insertions, 222 deletions
diff --git a/mcs/class/I18N/Rare/CP1026.cs b/mcs/class/I18N/Rare/CP1026.cs
index 997411d6600..579f2ad5423 100644
--- a/mcs/class/I18N/Rare/CP1026.cs
+++ b/mcs/class/I18N/Rare/CP1026.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1026.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1026 : ByteEncoding
'\u0022', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1026 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1047.cs b/mcs/class/I18N/Rare/CP1047.cs
index 9f6565b6a90..95fa1fda9b5 100644
--- a/mcs/class/I18N/Rare/CP1047.cs
+++ b/mcs/class/I18N/Rare/CP1047.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1047.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1047 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1047 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1140.cs b/mcs/class/I18N/Rare/CP1140.cs
index eac9ae01a72..8d050ce3d08 100644
--- a/mcs/class/I18N/Rare/CP1140.cs
+++ b/mcs/class/I18N/Rare/CP1140.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1140.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1140 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1140 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1141.cs b/mcs/class/I18N/Rare/CP1141.cs
index 40ad50b3e61..e197bbccdf9 100644
--- a/mcs/class/I18N/Rare/CP1141.cs
+++ b/mcs/class/I18N/Rare/CP1141.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1141.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1141 : ByteEncoding
'\u005D', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1141 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1142.cs b/mcs/class/I18N/Rare/CP1142.cs
index 71291152d5a..797616127ab 100644
--- a/mcs/class/I18N/Rare/CP1142.cs
+++ b/mcs/class/I18N/Rare/CP1142.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1142.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1142 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1142 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1143.cs b/mcs/class/I18N/Rare/CP1143.cs
index 19f6b20c4c2..c4bcc93526c 100644
--- a/mcs/class/I18N/Rare/CP1143.cs
+++ b/mcs/class/I18N/Rare/CP1143.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1143.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1143 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1143 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1144.cs b/mcs/class/I18N/Rare/CP1144.cs
index d13639c4533..c09c4c4fd9a 100644
--- a/mcs/class/I18N/Rare/CP1144.cs
+++ b/mcs/class/I18N/Rare/CP1144.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1144.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1144 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1144 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1145.cs b/mcs/class/I18N/Rare/CP1145.cs
index e73777b163a..149c06d42a9 100644
--- a/mcs/class/I18N/Rare/CP1145.cs
+++ b/mcs/class/I18N/Rare/CP1145.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1145.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1145 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1145 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1146.cs b/mcs/class/I18N/Rare/CP1146.cs
index 5ba6e41cbd0..f3749ad6fd8 100644
--- a/mcs/class/I18N/Rare/CP1146.cs
+++ b/mcs/class/I18N/Rare/CP1146.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1146.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1146 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1146 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1147.cs b/mcs/class/I18N/Rare/CP1147.cs
index 84bf298732a..ce19306a336 100644
--- a/mcs/class/I18N/Rare/CP1147.cs
+++ b/mcs/class/I18N/Rare/CP1147.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1147.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1147 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1147 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1148.cs b/mcs/class/I18N/Rare/CP1148.cs
index bdcbbb39e58..923393e045a 100644
--- a/mcs/class/I18N/Rare/CP1148.cs
+++ b/mcs/class/I18N/Rare/CP1148.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1148.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1148 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1148 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP1149.cs b/mcs/class/I18N/Rare/CP1149.cs
index e29d088c617..8e61e908d92 100644
--- a/mcs/class/I18N/Rare/CP1149.cs
+++ b/mcs/class/I18N/Rare/CP1149.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1149.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP1149 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP1149 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20273.cs b/mcs/class/I18N/Rare/CP20273.cs
index 716ba7dd86e..dff98a4db78 100644
--- a/mcs/class/I18N/Rare/CP20273.cs
+++ b/mcs/class/I18N/Rare/CP20273.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-273.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20273 : ByteEncoding
'\u005D', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20273 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20277.cs b/mcs/class/I18N/Rare/CP20277.cs
index 67f54633417..705f8bf4049 100644
--- a/mcs/class/I18N/Rare/CP20277.cs
+++ b/mcs/class/I18N/Rare/CP20277.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-277.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20277 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20277 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20278.cs b/mcs/class/I18N/Rare/CP20278.cs
index 7ed1a6e2a2d..2bcb65418c6 100644
--- a/mcs/class/I18N/Rare/CP20278.cs
+++ b/mcs/class/I18N/Rare/CP20278.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-278.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20278 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20278 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20280.cs b/mcs/class/I18N/Rare/CP20280.cs
index d7fc172d80b..b6c1e9ded98 100644
--- a/mcs/class/I18N/Rare/CP20280.cs
+++ b/mcs/class/I18N/Rare/CP20280.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-280.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20280 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20280 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20284.cs b/mcs/class/I18N/Rare/CP20284.cs
index 7a93a9ec7a8..5197213a1bb 100644
--- a/mcs/class/I18N/Rare/CP20284.cs
+++ b/mcs/class/I18N/Rare/CP20284.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-284.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20284 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20284 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20285.cs b/mcs/class/I18N/Rare/CP20285.cs
index 6c8cbfff1ac..1c52500f341 100644
--- a/mcs/class/I18N/Rare/CP20285.cs
+++ b/mcs/class/I18N/Rare/CP20285.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-285.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20285 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20285 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20290.cs b/mcs/class/I18N/Rare/CP20290.cs
index e3a603ad200..801e9032eb8 100644
--- a/mcs/class/I18N/Rare/CP20290.cs
+++ b/mcs/class/I18N/Rare/CP20290.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-290.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20290 : ByteEncoding
'\u003F', '\u003F', '\u003F', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -472,15 +521,26 @@ public class CP20290 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20297.cs b/mcs/class/I18N/Rare/CP20297.cs
index cbd04191cfb..25d61b43a8a 100644
--- a/mcs/class/I18N/Rare/CP20297.cs
+++ b/mcs/class/I18N/Rare/CP20297.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-297.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20297 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20297 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20420.cs b/mcs/class/I18N/Rare/CP20420.cs
index 11bb818b19b..252aaee2e54 100644
--- a/mcs/class/I18N/Rare/CP20420.cs
+++ b/mcs/class/I18N/Rare/CP20420.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-420.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20420 : ByteEncoding
'\u0667', '\u0668', '\u0669', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -576,15 +625,26 @@ public class CP20420 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20424.cs b/mcs/class/I18N/Rare/CP20424.cs
index 109127ef65a..20f49855702 100644
--- a/mcs/class/I18N/Rare/CP20424.cs
+++ b/mcs/class/I18N/Rare/CP20424.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-424.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20424 : ByteEncoding
'\u003F', '\u003F', '\u003F', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -454,15 +503,26 @@ public class CP20424 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP20871.cs b/mcs/class/I18N/Rare/CP20871.cs
index 1b6752d0121..87af1698cf3 100644
--- a/mcs/class/I18N/Rare/CP20871.cs
+++ b/mcs/class/I18N/Rare/CP20871.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-871.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP20871 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP20871 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP21025.cs b/mcs/class/I18N/Rare/CP21025.cs
index 709a12a77ff..2a2cf90dba5 100644
--- a/mcs/class/I18N/Rare/CP21025.cs
+++ b/mcs/class/I18N/Rare/CP21025.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1025.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP21025 : ByteEncoding
'\u042D', '\u0429', '\u0427', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -498,15 +547,26 @@ public class CP21025 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP37.cs b/mcs/class/I18N/Rare/CP37.cs
index 8f1556a355b..f31ecdf0411 100644
--- a/mcs/class/I18N/Rare/CP37.cs
+++ b/mcs/class/I18N/Rare/CP37.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-37.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP37 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP37 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP500.cs b/mcs/class/I18N/Rare/CP500.cs
index 0bc772d8203..fdee8f1c48f 100644
--- a/mcs/class/I18N/Rare/CP500.cs
+++ b/mcs/class/I18N/Rare/CP500.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-500.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP500 : ByteEncoding
'\u00DC', '\u00D9', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -488,15 +537,26 @@ public class CP500 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP708.cs b/mcs/class/I18N/Rare/CP708.cs
index 842e4c7da11..94a1fe04a1e 100644
--- a/mcs/class/I18N/Rare/CP708.cs
+++ b/mcs/class/I18N/Rare/CP708.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-1089.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP708 : ByteEncoding
'\u003F', '\u003F', '\u003F', '\u003F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 161) switch(ch)
{
case 0x00A4:
@@ -305,20 +354,36 @@ public class CP708 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -536,9 +601,13 @@ public class CP708 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP852.cs b/mcs/class/I18N/Rare/CP852.cs
index 66286255777..1f079a7e0a9 100644
--- a/mcs/class/I18N/Rare/CP852.cs
+++ b/mcs/class/I18N/Rare/CP852.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-852.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP852 : ByteEncoding
'\u0158', '\u0159', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -372,20 +421,36 @@ public class CP852 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -670,9 +735,13 @@ public class CP852 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP855.cs b/mcs/class/I18N/Rare/CP855.cs
index bf229668299..3dd917214ac 100644
--- a/mcs/class/I18N/Rare/CP855.cs
+++ b/mcs/class/I18N/Rare/CP855.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-855.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP855 : ByteEncoding
'\u0427', '\u00A7', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -372,20 +421,36 @@ public class CP855 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -670,9 +735,13 @@ public class CP855 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP857.cs b/mcs/class/I18N/Rare/CP857.cs
index c9cf4bd04d6..d40c5410928 100644
--- a/mcs/class/I18N/Rare/CP857.cs
+++ b/mcs/class/I18N/Rare/CP857.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-857.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP857 : ByteEncoding
'\u00B3', '\u00B2', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -369,20 +418,36 @@ public class CP857 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -664,9 +729,13 @@ public class CP857 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP858.cs b/mcs/class/I18N/Rare/CP858.cs
index 720ee1e6f37..f85ef1ac81f 100644
--- a/mcs/class/I18N/Rare/CP858.cs
+++ b/mcs/class/I18N/Rare/CP858.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-858.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP858 : ByteEncoding
'\u00B3', '\u00B2', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -372,20 +421,36 @@ public class CP858 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -670,9 +735,13 @@ public class CP858 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP862.cs b/mcs/class/I18N/Rare/CP862.cs
index 93510c28df0..17b687c8131 100644
--- a/mcs/class/I18N/Rare/CP862.cs
+++ b/mcs/class/I18N/Rare/CP862.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-862.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP862 : ByteEncoding
'\u207F', '\u00B2', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -375,20 +424,36 @@ public class CP862 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -676,9 +741,13 @@ public class CP862 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP864.cs b/mcs/class/I18N/Rare/CP864.cs
index e7e4f743d64..6b0f86b467e 100644
--- a/mcs/class/I18N/Rare/CP864.cs
+++ b/mcs/class/I18N/Rare/CP864.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-864.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP864 : ByteEncoding
'\uFED9', '\uFEF1', '\u25A0', '\u003F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -463,20 +512,36 @@ public class CP864 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -852,9 +917,13 @@ public class CP864 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP866.cs b/mcs/class/I18N/Rare/CP866.cs
index 7bed8f05b98..b663fccc832 100644
--- a/mcs/class/I18N/Rare/CP866.cs
+++ b/mcs/class/I18N/Rare/CP866.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-866.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP866 : ByteEncoding
'\u2116', '\u00A4', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -377,20 +426,36 @@ public class CP866 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -680,9 +745,13 @@ public class CP866 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP869.cs b/mcs/class/I18N/Rare/CP869.cs
index 3939de3567f..16ffb17f930 100644
--- a/mcs/class/I18N/Rare/CP869.cs
+++ b/mcs/class/I18N/Rare/CP869.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-869.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP869 : ByteEncoding
'\u03B0', '\u03CE', '\u25A0', '\u00A0',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 26) switch(ch)
{
case 0x001B:
@@ -373,20 +422,36 @@ public class CP869 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
#if NET_2_0
+ //Execute fallback routine and set fallback flag on
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
+ }
}
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
@@ -672,9 +737,13 @@ public class CP869 : ByteEncoding
default:
{
if(ch >= 0xFF01 && ch <= 0xFF5E)
+ {
ch -= 0xFEE0;
+ }
else
+ {
ch = 0x3F;
+ }
}
break;
}
diff --git a/mcs/class/I18N/Rare/CP870.cs b/mcs/class/I18N/Rare/CP870.cs
index 290435390be..e9d3a318f19 100644
--- a/mcs/class/I18N/Rare/CP870.cs
+++ b/mcs/class/I18N/Rare/CP870.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-870.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP870 : ByteEncoding
'\u00DC', '\u0164', '\u00DA', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -487,15 +536,26 @@ public class CP870 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*
diff --git a/mcs/class/I18N/Rare/CP875.cs b/mcs/class/I18N/Rare/CP875.cs
index f5177058060..ef93f4e3ac4 100644
--- a/mcs/class/I18N/Rare/CP875.cs
+++ b/mcs/class/I18N/Rare/CP875.cs
@@ -24,6 +24,9 @@
// Generated from "ibm-875.ucm".
+// WARNING: Modifying this file directly might be a bad idea.
+// You should edit the code generator tools/ucm2cp.c instead for your changes
+// to appear in all relevant classes.
namespace I18N.Rare
{
@@ -86,18 +89,64 @@ public class CP875 : ByteEncoding
'\u003F', '\u003F', '\u00BB', '\u009F',
};
+ // Get the number of bytes needed to encode a character buffer.
+ public unsafe override int GetByteCountImpl (char* chars, int count)
+ {
+ if (this.EncoderFallback != null) {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ return GetBytesImpl(chars, count, null, 0);
+ }
+ else
+
+ {
+ return count;
+ }
+ }
+
+ // Get the number of bytes needed to encode a character buffer.
+ public override int GetByteCount (String s)
+ {
+ if (this.EncoderFallback != null)
+ {
+ //Calculate byte count by actually doing encoding and discarding the data.
+ unsafe
+ {
+ fixed (char *s_ptr = s)
+ {
+ return GetBytesImpl(s_ptr, s.Length, null, 0);
+ }
+ }
+ }
+ else
+ {
+ //byte count equals character count because no EncoderFallback set
+ return s.Length;
+ }
+ }
+
+ //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
protected unsafe override void ToBytes(char* chars, int charCount,
byte* bytes, int byteCount)
{
+ //Calling ToBytes with null destination buffer doesn't make any sense
+ if (bytes == null)
+ throw new ArgumentNullException("bytes");
+ GetBytesImpl(chars, charCount, bytes, byteCount);
+ }
+
+ public unsafe override int GetBytesImpl (char* chars, int charCount,
+ byte* bytes, int byteCount)
+ {
int ch;
- int charIndex = 0;
+ int charIndex;
int byteIndex = 0;
#if NET_2_0
EncoderFallbackBuffer buffer = null;
#endif
- while(charCount > 0)
+ for (charIndex=0; charCount > 0; charIndex++, charCount--)
{
- ch = (int)(chars[charIndex++]);
+ ch = (int)(chars[charIndex]);
+ bool fallback = false;
if(ch >= 4) switch(ch)
{
case 0x000B:
@@ -496,15 +545,26 @@ public class CP875 : ByteEncoding
default:
#if NET_2_0
HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+ fallback = true;
#else
ch = 0x3F;
#endif
break;
}
- bytes[byteIndex++] = (byte)ch;
- --charCount;
- --byteCount;
+ //Write encoded byte to buffer, if buffer is defined and fallback was not used
+ if (bytes != null && !fallback)
+ {
+ bytes[byteIndex] = (byte)ch;
+ }
+
+ //Bump counters if fallback was not used
+ if (!fallback)
+ {
+ byteIndex++;
+ byteCount--;
+ }
}
+ return byteIndex;
}
/*