See here:
http://www.purebasic.fr/english/viewtop ... 50#p474250
Print / PrintN with Flag #PB_Ascii / #PB_UTF8 / #PB_Unicode
Print / PrintN with Flag #PB_Ascii / #PB_UTF8 / #PB_Unicode
sorry for my bad english
Re: Print / PrintN with Flag #PB_Ascii / #PB_UTF8 / #PB_Unic
+1 This would be useful.
Here is a workaround
Here is a workaround
Code: Select all
Procedure _Print(Text.s, Format.i)
If (Text)
Protected Bytes.i, *Mem
If (Format = #PB_Default)
CompilerIf (#PB_Compiler_Unicode)
Format = #PB_Unicode
CompilerElse
Format = #PB_Ascii
CompilerEndIf
EndIf
Select (Format)
Case #PB_Ascii
Bytes = StringByteLength(Text, #PB_Ascii)
*Mem = AllocateMemory(Bytes)
If (*Mem)
PokeS(*Mem, Text, -1, #PB_Ascii | #PB_String_NoZero)
EndIf
Case #PB_UTF8
Bytes = StringByteLength(Text, #PB_UTF8)
*Mem = AllocateMemory(Bytes)
If (*Mem)
PokeS(*Mem, Text, -1, #PB_UTF8 | #PB_String_NoZero)
EndIf
Case #PB_Unicode
Bytes = StringByteLength(Text, #PB_Unicode)
*Mem = AllocateMemory(Bytes)
If (*Mem)
PokeS(*Mem, Text, -1, #PB_Unicode | #PB_String_NoZero)
EndIf
EndSelect
If (*Mem)
WriteConsoleData(*Mem, Bytes)
FreeMemory(*Mem)
EndIf
EndIf
EndProcedure
Macro Print(Text, Format = #PB_Default)
_Print(Text, (Format))
EndMacro
Macro PrintN(Text, Format = #PB_Default)
CompilerIf (#PB_Compiler_OS = #PB_OS_Windows)
Print(Text + #CRLF$, (Format))
CompilerElse
Print(Text + #LF$, (Format))
CompilerEndIf
EndMacro
Re: Print / PrintN with Flag #PB_Ascii / #PB_UTF8 / #PB_Unic
And a Flag for OEM: Print("blabla", #PB_OEMtoCHAR)
Print("blabla", #PB_CHARtoOEM)
Print("blabla", #PB_CHARtoOEM)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: Print / PrintN with Flag #PB_Ascii / #PB_UTF8 / #PB_Unic
Not only the Print() function, but all the Console related functions should get codepage options.
WriteProgramString
ConsoleError
ReadProgramError
...
WriteProgramString
ConsoleError
ReadProgramError
...