This repository was archived by the owner on Jul 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed
Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -293,12 +293,13 @@ def OpenDocument(self):
293293 stream = File .OpenRead (filename )
294294
295295 buff = System .Array .CreateInstance (System .Byte , 1024 )
296+ buff .Initialize ()
296297 data = []
298+ read = 1
297299
298- while stream .Position < stream .Length :
299- buff .Initialize ()
300- stream .Read (buff , 0 , 1024 )
301- temp = Encoding .ASCII .GetString (buff , 0 , 1024 )
300+ while read > 0 :
301+ read , _ = stream .Read (buff , 0 , 1024 )
302+ temp = Encoding .ASCII .GetString (buff , 0 , read )
302303 data .append (temp )
303304
304305 data = '' .join (data )
Original file line number Diff line number Diff line change @@ -759,6 +759,28 @@ def test():
759759
760760 self .assertRaises (TypeError , test )
761761
762+ def testWeCanBindToEncodingGetString (self ):
763+ """Check that we can bind to the Encoding.GetString method with variables."""
764+
765+ from System .Text import Encoding
766+ from System .IO import MemoryStream
767+ myBytes = Encoding .UTF8 .GetBytes ('Some testing string' )
768+ stream = MemoryStream ()
769+ stream .Write (myBytes , 0 , myBytes .Length )
770+ stream .Position = 0
771+
772+ buff = System .Array .CreateInstance (System .Byte , 3 )
773+ buff .Initialize ()
774+ data = []
775+ read = 1
776+
777+ while read > 0 :
778+ read , _ = stream .Read (buff , 0 , buff .Length )
779+ temp = Encoding .UTF8 .GetString (buff , 0 , read )
780+ data .append (temp )
781+
782+ data = '' .join (data )
783+ self .assertEqual (data , 'Some testing string' )
762784
763785def test_suite ():
764786 return unittest .makeSuite (MethodTests )
You can’t perform that action at this time.
0 commit comments