Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

[MBS] Bad string problem manifesting itself in RB5 (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] Let's talk about the updates
Next thread: Re: [MBS] ICQ?


Re: [MBS] MIDI Destinations and External Devices   -   Ron Benditt
  [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
   Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
    Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz
     Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
      Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz
       Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
        Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz
         Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
          Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz
           Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
            Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz
             Re: [MBS] Bad string problem manifesting itself in RB5   -   Travis Hill
              Re: [MBS] Bad string problem manifesting itself in RB5   -   Christian Schmitz

[MBS] Bad string problem manifesting itself in RB5
Date: 04.01.03 10:46 (Sat, 4 Jan 2003 02:46:59 -0700)
From: Travis Hill
There is something improper about the way MBS is returning string
information. Other plugins that return strings seem to work fine under
RB5, but the MBS ones (at least from the JPEG stuff) seem to be corrupt
somehow. Here is my example code that shows this in a listbox:

Dim TempStr As String

TempStr = PictureToJPEGString(ScreenShot, 80)

ListBox1.AddRow Str(LenB(TempStr))
TempStr = TempStr + "a"
ListBox1.AddRow Str(LenB(TempStr))

You will notice that the first call to LenB seems to return a
reasonable length, but after the string concat operation, the string
has become thousands of bytes longer according to LenB rather than just
one. It seems as if the string is corrupt.

I don't know if this is limited to the jpeg/image functions or not- but
it seems like something specific in MBS that needs resolving. Other
plugins that return strings do not demonstrate the problem.

Could you look into this ASAP Christian?

Thanks!

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 04.01.03 11:16 (Sat, 4 Jan 2003 03:16:21 -0700)
From: Travis Hill
Just as a follow-up to myself, I believe I know what the problem is:

When returning binary data in a string, the encoding should be set to
something like US-ASCII, which is textencoding base 1536. I'm guessing
that the issue is that before RB5, encodings weren't really played with
much at all- and now they are obeyed when string operations come into
play.

So I guess what needs changing is defaulting the encodings of
binary-data strings to the correct encoding, and then it seems
everything is great.

If you could stick that in, I'd appreciate it.

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 16:31 (Sun, 5 Jan 2003 16:31:59 +0100)
From: Christian Schmitz
> Just as a follow-up to myself, I believe I know what the problem is:
>
> When returning binary data in a string, the encoding should be set to
> something like US-ASCII, which is textencoding base 1536. I'm guessing
> that the issue is that before RB5, encodings weren't really played with
> much at all- and now they are obeyed when string operations come into
> play.

I use my constant encodingBinary which has the value 0 like MacRoman.
it may be that RB encodes the JPEG string to UTF8.

If I return ASCII, I've invalid values in the string and RB will destroy
it with the reconverting to UTF8. (e.g. ? for ASCII values >128).

You can try it youself using:

setstringencoding s,1536

And than try it.

Mfg
Christian

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 04.01.03 19:54 (Sat, 4 Jan 2003 11:54:36 -0700)
From: Travis Hill
That's what I did: When the encoding is set to 1536 prior to doing
anything else with the string, concat operations work fine and the
binary information is left in-tact.

When it is not set and left at 0, the string gets messed up during the
concat.

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 21:18 (Sun, 5 Jan 2003 21:18:56 +0100)
From: Christian Schmitz
> That's what I did: When the encoding is set to 1536 prior to doing
> anything else with the string, concat operations work fine and the
> binary information is left in-tact.
>
> When it is not set and left at 0, the string gets messed up during the
> concat.

Than I must add to the help that it may be required to change the
encoding to avoid REALbasic to mess it up.

I can't set it to ASCII because it's not an ASCII string.

Mfg
Christian

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 21:32 (Sun, 5 Jan 2003 13:32:36 -0700)
From: Travis Hill
Well just to play devils advocate (heheh), why not set the encoding to
ASCII?

When its set to ASCII all the binary data is intact, and string
operations work properly. When it is not, they don't.

What exactly breaks down when the encoding is set to ASCII?

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 21:48 (Sun, 5 Jan 2003 21:48:15 +0100)
From: Christian Schmitz
> What exactly breaks down when the encoding is set to ASCII?

Just an example what happens

dim t as TextConverter

t=GetTextConverter(GetTextEncoding(1536),GetTextEncoding(0))

MsgBox t.convert("äüö")

RB will destroy your JPEG string if it's not the same encoding as the
other string.

Mfg
Christian

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 04.01.03 21:59 (Sat, 4 Jan 2003 13:59:06 -0700)
From: Travis Hill
Ah-ha, so maybe now I am finally starting to understand. :)

Because strings created on my system by default are US-ASCII, if I set
the encoding of the JPEG string to that, it doesn't get mangled.

So are default encodings different on different systems? Like when I
go:

NewString = "a" + myjpegstring

Is "a" always US-ASCII or does it vary?

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 22:08 (Sun, 5 Jan 2003 22:08:08 +0100)
From: Christian Schmitz
> Ah-ha, so maybe now I am finally starting to understand. :)
>
> Because strings created on my system by default are US-ASCII, if I set
> the encoding of the JPEG string to that, it doesn't get mangled.

MsgBox str(GetStringEncoding("Hello")) -> 1536
MsgBox str(GetStringEncoding("Nächster")) -> 65535

Interesting, or?

Maybe you can try in RB5 what values are generated on different strings.
You can use the charset table from the keyboard menu on Mac OS X 10.2 to
create some chinese text...

For the JPEG string you may prefer to use this:

a=JPEGString
b=AddString

setstringencoding(a,getstringencoding(b))

c=a+b

and it should work.

mfg
Christian

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 22:18 (Sun, 5 Jan 2003 14:18:44 -0700)
From: Travis Hill
Yes, using that technique and similar ones does fix the problem.
*phew* I'm feeling so much better now thank you. :)

So are you still going to change binary strings to be the unknown
encoding (65535) in the future?

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 22:26 (Sun, 5 Jan 2003 22:26:46 +0100)
From: Christian Schmitz
> So are you still going to change binary strings to be the unknown
> encoding (65535) in the future?

Not until RS officially suggests that for plugin developers.

Mfg
Christian

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 05.01.03 22:44 (Sun, 5 Jan 2003 14:44:08 -0700)
From: Travis Hill
Did you catch Joe's reply on the beta's list? Not quite an official
suggestion but it seems pretty close.

---
I agree. Best would be to set the encoding to 0xFFFF, which is the
unknown encoding. This is the most honest answer (anything else claims
that it's some text encoding, when really it is none of them), and also
prevents the data from being passed automatically through text
converters when (for example) it's added to another string of some
other encoding.
---

BTW thanks for your help...

Re: [MBS] Bad string problem manifesting itself in RB5
Date: 06.01.03 00:07 (Mon, 6 Jan 2003 00:07:46 +0100)
From: Christian Schmitz
> Did you catch Joe's reply on the beta's list? Not quite an official
> suggestion but it seems pretty close.

Ok. In the 3.0 plugins it will be changed...

Mfg
Christian