@@ -28,8 +28,8 @@ public override void Write( ushort data ) {
2828
2929 public override void Write ( string str ) {
3030 if ( str == null ) throw new ArgumentNullException ( "str" ) ;
31- if ( str . Length > 64 ) throw new ArgumentException ( "String is too long (>64)." , "str" ) ;
32- Write ( Encoding . ASCII . GetBytes ( str . PadRight ( 64 ) ) ) ;
31+ if ( str . Length > Packet . StringSize ) throw new ArgumentException ( "String is too long (>64)." , "str" ) ;
32+ Write ( Encoding . ASCII . GetBytes ( str . PadRight ( Packet . StringSize ) ) ) ;
3333 }
3434
3535
@@ -38,22 +38,21 @@ public static void WriteString(string str, byte[] array, int offset, bool hasCP4
3838 else WriteAscii ( str , array , offset ) ;
3939 }
4040
41- const int StringSize = 64 ;
4241 static void WriteAscii ( string str , byte [ ] array , int offset ) {
43- int count = Math . Min ( str . Length , StringSize ) ;
42+ int count = Math . Min ( str . Length , Packet . StringSize ) ;
4443 for ( int i = 0 ; i < count ; i ++ ) {
4544 char raw = str [ i ] . UnicodeToCp437 ( ) ;
4645 array [ offset + i ] = raw >= '\u0080 ' ? ( byte ) '?' : ( byte ) raw ;
4746 }
48- for ( int i = count ; i < StringSize ; i ++ )
47+ for ( int i = count ; i < Packet . StringSize ; i ++ )
4948 array [ offset + i ] = ( byte ) ' ' ;
5049 }
5150
5251 static void WriteCP437 ( string str , byte [ ] array , int offset ) {
53- int count = Math . Min ( str . Length , StringSize ) ;
52+ int count = Math . Min ( str . Length , Packet . StringSize ) ;
5453 for ( int i = 0 ; i < count ; i ++ )
5554 array [ offset + i ] = ( byte ) str [ i ] . UnicodeToCp437 ( ) ;
56- for ( int i = count ; i < StringSize ; i ++ )
55+ for ( int i = count ; i < Packet . StringSize ; i ++ )
5756 array [ offset + i ] = ( byte ) ' ' ;
5857 }
5958 }
0 commit comments