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:
Diffstat (limited to 'mcs/class/I18N/CJK/CP51932.cs')
-rw-r--r--mcs/class/I18N/CJK/CP51932.cs80
1 files changed, 62 insertions, 18 deletions
diff --git a/mcs/class/I18N/CJK/CP51932.cs b/mcs/class/I18N/CJK/CP51932.cs
index bffb15ba77b..fcf9e828006 100644
--- a/mcs/class/I18N/CJK/CP51932.cs
+++ b/mcs/class/I18N/CJK/CP51932.cs
@@ -65,7 +65,7 @@ public class CP51932 : MonoEncoding
private const int EUC_JP_CODE_PAGE = 51932;
// Constructor.
- public CP51932 () : base (EUC_JP_CODE_PAGE, 932)
+ public CP51932 () : base (EUC_JP_CODE_PAGE)
{
}
@@ -75,11 +75,6 @@ public class CP51932 : MonoEncoding
return new CP51932Encoder (this).GetByteCount (chars, index, length, true);
}
- public unsafe override int GetByteCountImpl (char* chars, int count)
- {
- return new CP51932Encoder (this).GetByteCountImpl (chars, count, true);
- }
-
public unsafe override int GetBytesImpl (char* chars, int charCount, byte* bytes, int byteCount)
{
return new CP51932Encoder (this).GetBytesImpl (chars, charCount, bytes, byteCount, true);
@@ -186,10 +181,15 @@ public class CP51932 : MonoEncoding
public override String WebName {
get { return "euc-jp"; }
}
+
+ // Get the Windows code page represented by this object.
+ public override int WindowsCodePage {
+ get { return EUC_JP_CODE_PAGE; }
+ }
} // CP51932
#endif // !ECMA_COMPAT
-public class CP51932Encoder : MonoEncoder
+public class CP51932Encoder : MonoEncoding.MonoEncoder
{
public CP51932Encoder (MonoEncoding encoding)
: base (encoding)
@@ -197,11 +197,22 @@ public class CP51932Encoder : MonoEncoder
}
// Get the number of bytes needed to encode a character buffer.
- public unsafe override int GetByteCountImpl (
- char* chars, int count, bool refresh)
+ public override int GetByteCount (
+ char [] chars, int index, int count, bool refresh)
{
+ // Validate the parameters.
+ if (chars == null)
+ throw new ArgumentNullException("chars");
+
+ if (index < 0 || index > chars.Length)
+ throw new ArgumentOutOfRangeException
+ ("index", Strings.GetString ("ArgRange_Array"));
+
+ if (count < 0 || count > (chars.Length - index))
+ throw new ArgumentOutOfRangeException
+ ("count", Strings.GetString ("ArgRange_Array"));
+
// Determine the length of the final output.
- int index = 0;
int length = 0;
int ch, value;
byte [] cjkToJis = JISConvert.Convert.cjkToJis;
@@ -255,6 +266,9 @@ public class CP51932Encoder : MonoEncoder
{
int charIndex = 0;
int byteIndex = 0;
+#if NET_2_0
+ EncoderFallbackBuffer buffer = null;
+#endif
// Convert the characters into their byte form.
int posn = byteIndex;
@@ -331,13 +345,8 @@ public class CP51932Encoder : MonoEncoder
}
} // CP51932Encoder
-internal class CP51932Decoder : DbcsEncoding.DbcsDecoder
+public class CP51932Decoder : Decoder
{
- public CP51932Decoder ()
- : base (null)
- {
- }
-
int last_count, last_bytes;
// Get the number of characters needed to decode a byte buffer.
@@ -353,7 +362,19 @@ internal class CP51932Decoder : DbcsEncoding.DbcsDecoder
#endif
int GetCharCount (byte [] bytes, int index, int count, bool refresh)
{
- CheckRange (bytes, index, count);
+ // Validate the parameters.
+ if (bytes == null)
+ throw new ArgumentNullException ("bytes");
+
+ if (index < 0 || index > bytes.Length)
+ throw new ArgumentOutOfRangeException
+ ("index", Strings.GetString("ArgRange_Array"));
+
+ if (count < 0 || count > (bytes.Length - index))
+ throw new ArgumentOutOfRangeException
+ ("count", Strings.GetString("ArgRange_Array"));
+
+
// Determine the total length of the converted string.
int value = 0;
@@ -463,7 +484,30 @@ internal class CP51932Decoder : DbcsEncoding.DbcsDecoder
int byteCount, char[] chars,
int charIndex, bool refresh)
{
- CheckRange (bytes, byteIndex, byteCount, chars, charIndex);
+ // Validate the parameters.
+ if(bytes == null)
+ {
+ throw new ArgumentNullException("bytes");
+ }
+ if(chars == null)
+ {
+ throw new ArgumentNullException("chars");
+ }
+ if(byteIndex < 0 || byteIndex > bytes.Length)
+ {
+ throw new ArgumentOutOfRangeException
+ ("byteIndex", Strings.GetString("ArgRange_Array"));
+ }
+ if(byteCount < 0 || byteCount > (bytes.Length - byteIndex))
+ {
+ throw new ArgumentOutOfRangeException
+ ("byteCount", Strings.GetString("ArgRange_Array"));
+ }
+ if(charIndex < 0 || charIndex > chars.Length)
+ {
+ throw new ArgumentOutOfRangeException
+ ("charIndex", Strings.GetString("ArgRange_Array"));
+ }
// Decode the bytes in the buffer.
int posn = charIndex;