mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 07:18:34 -04:00
Use portable class library compatible alternatives for some methods.
This commit is contained in:
parent
1ed45db594
commit
cceecf2ae7
@ -25,7 +25,8 @@ namespace Launcher {
|
||||
public NameComparer( int column ) : base( column ) { }
|
||||
|
||||
protected override int Compare( ListViewItem x, ListViewItem y ) {
|
||||
int value = String.Compare( x.SubItems[col].Text, y.SubItems[col].Text, true );
|
||||
StringComparison comparison = StringComparison.CurrentCultureIgnoreCase;
|
||||
int value = String.Compare( x.SubItems[col].Text, y.SubItems[col].Text, comparison );
|
||||
return Invert ? -value : value;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,16 @@ namespace ClassicalSharp {
|
||||
|
||||
public string ReadString() {
|
||||
byte[] data = ReadBytes( 64 );
|
||||
return Encoding.ASCII.GetString( data ).TrimEnd( '\0', ' ' );
|
||||
return GetAsciiString( data ).TrimEnd( '\0', ' ' );
|
||||
}
|
||||
|
||||
static string GetAsciiString( byte[] data ) {
|
||||
char[] characters = new char[data.Length];
|
||||
for( int i = 0; i < data.Length; i++ ) {
|
||||
byte code = data[i];
|
||||
characters[i] = code >= 0x80 ? '?' : (char)code;
|
||||
}
|
||||
return new String( characters );
|
||||
}
|
||||
|
||||
static string GetTextString( byte[] data ) {
|
||||
|
@ -226,10 +226,14 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
static void WriteString( byte[] buffer, ref int index, string value ) {
|
||||
for( int i = index; i < index + 64; i++ ) {
|
||||
buffer[i] = (byte)' ';
|
||||
int count = Math.Min( value.Length, 64 );
|
||||
for( int i = 0; i < count; i++ ) {
|
||||
char c = value[i];
|
||||
buffer[index + i] = (byte)( c >= '\u0080' ? '?' : c );
|
||||
}
|
||||
for( int i = value.Length; i < 64; i++ ) {
|
||||
buffer[index + i] = (byte)' ';
|
||||
}
|
||||
Encoding.ASCII.GetBytes( value, 0, value.Length, buffer, index );
|
||||
index += 64;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user