ANSI output
BlitzMax Forums/BlitzMax Module Tweaks/ANSI output
| ||
Spetial characters are not propperly displayed on the windows console (accents, etc). This is a short TYPE that enables standard ANSI output when executing a BlitzMax application on windows. This way, spetial characters are propperly displayed on the standard windows console: Type ANSI function Print(Str:String = "") standardiostream.writebytes(str.tocstring(),len(str)) End Function Function PrintLine(str:String = "") local LineFeed:String = chr(13) + chr(10) str = str + linefeed standardiostream.writebytes(str.tocstring(),len(str)) End Function end type To use ANSI output just use: ANSI.Print(text$) or ANSI.PrintLine(text$) You can also add this to your code, if you want to mantain cross-platform compatibility, and evoiding recoding all your output statements: ?win32 function Print(str$ = "") ANSI.printLine(str) end function ? Adding this lines, your application will output ANSI characters on windows, and UTF8 in Macintosh and Linux just using the standard Print statement. Notice that you don't need this if your using a UTF8 compatible IDE like BLIde. |
| ||
If you don't want to control when you're using ANSI and when you're using UTF8, you just want everything to be printed properly, just add this lines in your code:?win32 function Print(Str:String = "") local LineFeed:String = chr(13) + chr(10) str = str + linefeed standardiostream.writebytes(str.tocstring(),len(str)) standardiostream.flush End Function ? This will change the WriteLine (wich converts by default) to a writebytes, wich mantains the original coding of the string, in windows. |