[Gambas-user] CryptoExample & gCrypto
Benoit Minisini
gambas at ...1...
Wed Jul 28 23:26:25 CEST 2004
On Wednesday 28 July 2004 23:05, Brant Wells wrote:
> Benoit Minisini wrote:
> >On Wednesday 28 July 2004 16:14, Brant Wells wrote:
> >>Hey Daniel:
> >>
> >>I agree completely. I think, though, that it will require some extra
> >>coding on our part... Linux uses a variety of Character Sets... where
> >>Windows uses ASCII or Unicode... Right?
> >
> >Not exactly, but this is not the problem :-)
>
> Brant Says: Do you know what the problem is?? If so... Do tell! :-P<>
More exactly, Windows use its own proprietary charsets: WINDOWS-936,
WINDOWS-1250, WINDOWS-1251, WINDOWS-1252..., and 16 bits Unicode.
>
> Benoit Minisini wrote:
> >The two conversions work on my machine, and I have a Mandrake 10 with
> >System.Charset = "ISO-8859-15" (It is ISO-8859-1 with the Euro sign).
> >
> >I tried with my first name :-) in the IDE console window.
> >
> >?Conv$("benoît", System.Charset, Desktop.Charset)
> >benoît
> >?Conv$("benoît", Desktop.Charset, System.Charset)
> >benoît
> >
> >Note that the console window does not use Desktop.Charset but
> > System.Charset to display strings.
>
> Brant Says:
> I get the same thing when I do System.Charset and Desktop.Charset...
> However, when I get unicode, it does this:
> ?conv("benoît",System.Charset,"Unicode")
> ÿþb [followed by 11 boxes... unprintable Unicode Chars, I'll assume...]
>
> ?conv("ÿþb ","Unicode",System.charset)
> Syntax error
>
> [Again, keep in mind that I assume the spaces after the ÿþb are
> unprintable Unicode Chars]...
>
> I'm at a loss for ideas as to how to work around this, to just make it
> work with Windoze... I understand that you are a Busy Man, like all of
> us, Benoit... But if you could maybe point me in the right direction,
> I'd really appreciate it!!!
You can't use Unicode directly with Gambas, because a string including '\0'
characters may be arbitrarily stripped while using Conv$() - This should not
happened, but I need to investigate to understand that.
But as a workaround, you can do the conversion character by character.
sStr = Conv$("benoît", Desktop.Charset, System.Charset)
for iInd = 1 to len(sStr)
sUnicode = sUnicode & Conv$(Mid$(sStr, iInd, 1), System.Charset,
"UNICODELITTLE")
next
You must convert your string to a charset that uses one byte by characters,
because at the moment, Gambas has no functions to manage UTF-8 strings at the
character level.
And you must use "UNICODELITTLE" to do the conversion. "UNICODE" is 32 bits
for each character, and Windows uses 16 bits UNICODE.
To know the name of all charsets managed by the system, type "iconv -l" in a
shell.
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list