[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Text UTF8Encoding.cs,1
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Text UTF8Encoding.cs,1.7,1.8 UnicodeEncoding.cs,1.7,1.8 |
Date: |
Thu, 28 Nov 2002 01:14:57 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Text
In directory subversions:/tmp/cvs-serv11610/runtime/System/Text
Modified Files:
UTF8Encoding.cs UnicodeEncoding.cs
Log Message:
Apply patches from the Mono project which remove unnecessary preambles
from UTF-8 and Unicode text streams.
Index: UTF8Encoding.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Text/UTF8Encoding.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** UTF8Encoding.cs 24 Aug 2002 22:39:59 -0000 1.7
--- UTF8Encoding.cs 28 Nov 2002 06:14:52 -0000 1.8
***************
*** 51,55 ****
private static int InternalGetByteCount(char[] chars, int index,
int count, uint leftOver,
!
bool emitIdentifier, bool flush)
{
// Validate the parameters.
--- 51,55 ----
private static int InternalGetByteCount(char[] chars, int index,
int count, uint leftOver,
!
bool flush)
{
// Validate the parameters.
***************
*** 123,127 ****
// Return the final length to the caller.
! return length + (emitIdentifier ? 3 : 0);
}
--- 123,127 ----
// Return the final length to the caller.
! return length;
}
***************
*** 129,134 ****
public override int GetByteCount(char[] chars, int index, int count)
{
! return InternalGetByteCount(chars, index,
count, 0,
!
emitIdentifier, true);
}
--- 129,133 ----
public override int GetByteCount(char[] chars, int index, int count)
{
! return InternalGetByteCount(chars, index,
count, 0, true);
}
***************
*** 182,186 ****
// Return the final length to the caller.
! return length + (emitIdentifier ? 3 : 0);
}
--- 181,185 ----
// Return the final length to the caller.
! return length;
}
***************
*** 190,194 ****
int
charCount, byte[] bytes,
int
byteIndex, ref uint leftOver,
!
bool emitIdentifier, bool flush)
{
// Validate the parameters.
--- 189,193 ----
int
charCount, byte[] bytes,
int
byteIndex, ref uint leftOver,
!
bool flush)
{
// Validate the parameters.
***************
*** 223,237 ****
uint left = leftOver;
int posn = byteIndex;
- if(emitIdentifier)
- {
- if((posn + 3) > length)
- {
- throw new ArgumentException
-
(_("Arg_InsufficientSpace"), "bytes");
- }
- bytes[posn++] = (byte)0xEF;
- bytes[posn++] = (byte)0xBB;
- bytes[posn++] = (byte)0xBF;
- }
while(charCount > 0)
{
--- 222,225 ----
***************
*** 343,348 ****
uint leftOver = 0;
return InternalGetBytes(chars, charIndex,
charCount,
!
bytes, byteIndex, ref leftOver,
!
emitIdentifier, true);
}
--- 331,335 ----
uint leftOver = 0;
return InternalGetBytes(chars, charIndex,
charCount,
!
bytes, byteIndex, ref leftOver, true);
}
***************
*** 381,395 ****
uint pair;
int posn = byteIndex;
- if(emitIdentifier)
- {
- if((posn + 3) > length)
- {
- throw new ArgumentException
-
(_("Arg_InsufficientSpace"), "bytes");
- }
- bytes[posn++] = (byte)0xEF;
- bytes[posn++] = (byte)0xBB;
- bytes[posn++] = (byte)0xBF;
- }
while(charCount > 0)
{
--- 368,371 ----
***************
*** 811,815 ****
("charCount",
_("ArgRange_NonNegative"));
}
! return charCount * 4 + (emitIdentifier ? 3 : 0);
}
--- 787,791 ----
("charCount",
_("ArgRange_NonNegative"));
}
! return charCount * 4;
}
***************
*** 835,839 ****
public override Encoder GetEncoder()
{
! return new UTF8Encoder(emitIdentifier);
}
--- 811,815 ----
public override Encoder GetEncoder()
{
! return new UTF8Encoder();
}
***************
*** 1002,1012 ****
private sealed class UTF8Encoder : Encoder
{
- private bool emitIdentifier;
private uint leftOver;
// Constructor.
! public UTF8Encoder(bool emitIdentifier)
{
- this.emitIdentifier = emitIdentifier;
leftOver = 0;
}
--- 978,986 ----
private sealed class UTF8Encoder : Encoder
{
private uint leftOver;
// Constructor.
! public UTF8Encoder()
{
leftOver = 0;
}
***************
*** 1017,1022 ****
{
return InternalGetByteCount
! (chars, index, count, leftOver,
! emitIdentifier, flush);
}
public override int GetBytes(char[] chars, int charIndex,
--- 991,995 ----
{
return InternalGetByteCount
! (chars, index, count, leftOver,
flush);
}
public override int GetBytes(char[] chars, int charIndex,
***************
*** 1027,1032 ****
result = InternalGetBytes
(chars, charIndex, charCount,
bytes, byteCount,
! ref leftOver, emitIdentifier,
flush);
! emitIdentifier = false;
return result;
}
--- 1000,1004 ----
result = InternalGetBytes
(chars, charIndex, charCount,
bytes, byteCount,
! ref leftOver, flush);
return result;
}
Index: UnicodeEncoding.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Text/UnicodeEncoding.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** UnicodeEncoding.cs 24 Aug 2002 22:39:59 -0000 1.7
--- UnicodeEncoding.cs 28 Nov 2002 06:14:52 -0000 1.8
***************
*** 71,75 ****
("count", _("ArgRange_Array"));
}
! return count * 2 + (byteOrderMark ? 2 : 0);
}
--- 71,75 ----
("count", _("ArgRange_Array"));
}
! return count * 2;
}
***************
*** 81,85 ****
throw new ArgumentNullException("s");
}
! return s.Length * 2 + (byteOrderMark ? 2 : 0);
}
--- 81,85 ----
throw new ArgumentNullException("s");
}
! return s.Length * 2;
}
***************
*** 111,116 ****
("byteIndex",
_("ArgRange_Array"));
}
! if((bytes.Length - byteIndex) <
! (charCount * 2 + (byteOrderMark ? 2 :
0)))
{
throw new ArgumentException
--- 111,115 ----
("byteIndex",
_("ArgRange_Array"));
}
! if((bytes.Length - byteIndex) < charCount * 2)
{
throw new ArgumentException
***************
*** 121,129 ****
if(bigEndian)
{
- if(byteOrderMark)
- {
- bytes[posn++] = (byte)0xFE;
- bytes[posn++] = (byte)0xFF;
- }
while(charCount-- > 0)
{
--- 120,123 ----
***************
*** 135,143 ****
else
{
- if(byteOrderMark)
- {
- bytes[posn++] = (byte)0xFF;
- bytes[posn++] = (byte)0xFE;
- }
while(charCount-- > 0)
{
--- 129,132 ----
***************
*** 177,182 ****
("byteIndex",
_("ArgRange_Array"));
}
! if((bytes.Length - byteIndex) <
! (charCount * 2 + (byteOrderMark ? 2 :
0)))
{
throw new ArgumentException
--- 166,170 ----
("byteIndex",
_("ArgRange_Array"));
}
! if((bytes.Length - byteIndex) < charCount * 2)
{
throw new ArgumentException
***************
*** 187,195 ****
if(bigEndian)
{
- if(byteOrderMark)
- {
- bytes[posn++] = (byte)0xFE;
- bytes[posn++] = (byte)0xFF;
- }
while(charCount-- > 0)
{
--- 175,178 ----
***************
*** 201,209 ****
else
{
- if(byteOrderMark)
- {
- bytes[posn++] = (byte)0xFF;
- bytes[posn++] = (byte)0xFE;
- }
while(charCount-- > 0)
{
--- 184,187 ----
***************
*** 341,345 ****
("charCount",
_("ArgRange_NonNegative"));
}
! return charCount * 2 + (byteOrderMark ? 2 : 0);
}
--- 319,323 ----
("charCount",
_("ArgRange_NonNegative"));
}
! return charCount * 2;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Text UTF8Encoding.cs,1.7,1.8 UnicodeEncoding.cs,1.7,1.8,
Rhys Weatherley <address@hidden> <=