Skip to content

Commit 0f4df0c

Browse files
committed
Fix extended ASCII characters for non unicode encodings (textmode console)
1 parent 72c8073 commit 0f4df0c

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

Aura Operating System/Aura_OS/Properties/VersionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace Aura_OS
22
{
33
public class VersionInfo
44
{
5-
public static string revision = "261220211247";
5+
public static string revision = "261220211352";
66
}
77
}

Aura Operating System/Aura_OS/System/AConsole/Console.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public Console()
4949

5050
public abstract void Write(char[] aText);
5151

52+
public abstract void Write(byte[] aText);
53+
5254
public abstract void UpdateCursor();
5355

5456
public abstract ConsoleColor Foreground { get; set; }

Aura Operating System/Aura_OS/System/AConsole/GraphicConsole.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ public override void Write(char[] aText)
193193
}
194194
}
195195

196+
public override void Write(byte[] aText)
197+
{
198+
throw new NotImplementedException();
199+
}
200+
196201
private void DoTab()
197202
{
198203
Write(Space);
@@ -205,6 +210,5 @@ public override void DrawImage(ushort X, ushort Y, Bitmap image)
205210
{
206211
graphics.canvas.DrawImage(image, X, Y);
207212
}
208-
209213
}
210214
}

Aura Operating System/Aura_OS/System/AConsole/TextConsole.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ private void DoCarriageReturn()
109109
[MethodImpl(MethodImplOptions.AggressiveInlining)]
110110
private void DoTab()
111111
{
112-
Write(Space);
113-
Write(Space);
114-
Write(Space);
115-
Write(Space);
112+
Write((byte)Space);
113+
Write((byte)Space);
114+
Write((byte)Space);
115+
Write((byte)Space);
116116
}
117117

118-
public void Write(char aChar)
118+
public void Write(byte aChar)
119119
{
120-
mText[mX, mY] = (byte)aChar;
120+
mText[mX, mY] = aChar;
121121
mX++;
122122
if (mX == mText.Cols)
123123
{
@@ -126,9 +126,14 @@ public void Write(char aChar)
126126
UpdateCursor();
127127
}
128128

129+
public override void Write(char[] aText)
130+
{
131+
throw new NotImplementedException();
132+
}
133+
129134
//TODO: Optimize this
130135
[MethodImpl(MethodImplOptions.AggressiveInlining)]
131-
public override void Write(char[] aText)
136+
public override void Write(byte[] aText)
132137
{
133138
if (aText == null)
134139
{
@@ -139,15 +144,15 @@ public override void Write(char[] aText)
139144
{
140145
switch (aText[i])
141146
{
142-
case LineFeed:
147+
case (byte)LineFeed:
143148
DoLineFeed();
144149
break;
145150

146-
case CarriageReturn:
151+
case (byte)CarriageReturn:
147152
DoCarriageReturn();
148153
break;
149154

150-
case Tab:
155+
case (byte)Tab:
151156
DoTab();
152157
break;
153158

Aura Operating System/Aura_Plugs/System/ConsoleImpl.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,15 @@ public static void Write(string aText)
852852
return;
853853
}
854854

855-
GetConsole().Write(aText.ToCharArray());
855+
if (ConsoleOutputEncoding.CodePage == 437 || ConsoleOutputEncoding.CodePage == 858)
856+
{
857+
byte[] aTextEncoded = ConsoleOutputEncoding.GetBytes(aText);
858+
GetConsole().Write(aTextEncoded);
859+
}
860+
else if (ConsoleOutputEncoding == Encoding.Unicode)
861+
{
862+
GetConsole().Write(aText.ToCharArray());
863+
}
856864
}
857865

858866
public static void Write(uint aInt) => Write(aInt.ToString());
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)