Hello,
I'm just wondering if older versions of PureBasic converted utf8 encoded commandline parameters to Unicode automatically? With PB5.21 I get the utf8 encoded string as unicode. This is ok so far and I can solve by using PeekS() and PokesS() but I think that older PB versions converted the utf8 parameter to unicode by themselves?
Any hints about this and how to deal with such commandline parameters?
Kukulkan
ProgramParameter() and utf8
Re: ProgramParameter() and utf8
IIRC, these commands never converted from utf8 to unicode automatically.
Re: ProgramParameter() and utf8
Ok, thanks Fred.
So I think UTF8 and manual conversion is the only way to securely submit commandline parameters to a PureBasic application if they contain unicode characters, right?
Kukulkan
So I think UTF8 and manual conversion is the only way to securely submit commandline parameters to a PureBasic application if they contain unicode characters, right?
Kukulkan
Re: ProgramParameter() and utf8
You mean on Linux or Windows ?
Re: ProgramParameter() and utf8
Both. My application gets compiled on Windows, Linux and MacOS. I like to have it the same behaviour on all platforms. I think utf8 is the best. Do you agree?
As I'm compiling in Unicode, I have to convert the utf8 parameters to Unicode in my code:
Best
Kukulkan
As I'm compiling in Unicode, I have to convert the utf8 parameters to Unicode in my code:
Code: Select all
Procedure.s ConvertUTF8toUnicode(utf8String.s)
; works only if compiled in unicode mode!
Protected result.s = ""
Protected *a = AllocateMemory(Len(utf8String.s)+1)
; poke it as ascii
PokeS(*a, utf8String.s,-1,#PB_Ascii)
; peek it as utf8
result.s = PeekS(*a, -1, #PB_UTF8)
FreeMemory(*a)
ProcedureReturn result.s
EndProcedureKukulkan

