* OTHER DEALINGS IN THE SOFTWARE.
*/
-#if NET_2_0
-
namespace System.Text
{
{
}
- public UTF32Encoding (bool bigEndian, bool byteOrderMark, bool throwOnInvalid)
+ public UTF32Encoding (bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters)
: base ((bigEndian ? BIG_UTF32_CODE_PAGE : UTF32_CODE_PAGE))
{
this.bigEndian = bigEndian;
this.byteOrderMark = byteOrderMark;
- if (throwOnInvalid)
+ if (throwOnInvalidCharacters)
SetFallbackInternal (EncoderFallback.ExceptionFallback,
DecoderFallback.ExceptionFallback);
else
- SetFallbackInternal (EncoderFallback.ReplacementFallback,
- DecoderFallback.ReplacementFallback);
+ SetFallbackInternal (new EncoderReplacementFallback ("\uFFFD"),
+ new DecoderReplacementFallback ("\uFFFD"));
if (bigEndian){
body_name = "utf-32BE";
encoding_name = "UTF-32 (Big-Endian)";
header_name = "utf-32BE";
- is_browser_save = false;
web_name = "utf-32BE";
} else {
body_name = "utf-32";
encoding_name = "UTF-32";
header_name = "utf-32";
- is_browser_save = true;
web_name = "utf-32";
}
throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
}
int ret = 0;
- for (int i = index; i < count; i++) {
+ for (int i = index; i < index + count; i++) {
if (Char.IsSurrogate (chars [i])) {
if (i + 1 < chars.Length && Char.IsSurrogate (chars [i + 1]))
ret += 4;
public override byte[] GetPreamble ()
{
if (byteOrderMark) {
- byte[] preamble = new byte[2];
+ byte[] preamble = new byte[4];
if (bigEndian) {
- preamble[0] = (byte)0xFE;
- preamble[1] = (byte)0xFF;
+ preamble[2] = (byte)0xFE;
+ preamble[3] = (byte)0xFF;
} else {
preamble[0] = (byte)0xFF;
preamble[1] = (byte)0xFE;
}
return preamble;
- } else {
- return new byte [0];
}
+
+ return EmptyArray<byte>.Value;
}
// Determine if this object is equal to another.
} // class UTF32Decoder
-#if NET_2_0
[CLSCompliantAttribute(false)]
public unsafe override int GetByteCount (char *chars, int count)
{
+ if (chars == null)
+ throw new ArgumentNullException ("chars");
return count * 4;
}
-#else
- public override byte [] GetBytes (String s)
- {
- return base.GetBytes (s);
- }
-#endif
-#if NET_2_0
// a bunch of practically missing implementations (but should just work)
public override int GetByteCount (string s)
{
return base.GetEncoder ();
}
-#endif
-
}; // class UTF32Encoding
}; // namespace System.Text
-
-#endif