Double byte trouble

Richmond Mathewson richmondmathewson at gmail.com
Wed Aug 17 13:31:15 EDT 2011


On 08/16/2011 10:51 PM, Mark Schonewille wrote:
> Hi Richmond,
>
> I wrote this yesterday already. The availability of byte and char indicate that RunRev is aware of this problem. Unfortunately, RunRev hasn't actually taken action to solve it yet.
>
> For now, it is just a fact that fields who have the unicodeText property set, need two bytes for a character and will return only the first byte of a character when you retrieve char 1 of that field.
>
> That said, have you tried getting char 1 of the text of fld x? Does that help?
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
> KvK: 50277553
>
> What does that error mean? Buy LiveCodeErrors for iPhone now http://qery.us/v4 A must-have for LiveCode programmers.
>
> On 16 aug 2011, at 21:06, Richmond Mathewson wrote:
>
>> I did this:
>>
>> set the useUnicode to true
>> set the unicodeText of fld "INN" to numToChar(69)
>>
>> and, unsurprisingly, an 'E' appeared in fld "INN"
>>
>> when I then did this:
>>
>> delete char 1 of fld "INN"   'E' vanished; again, unsurprisingly
>>
>> when I put a spot of unicodeText in my fld "INN"
>> the "delete char 1" script MADE THE FIRST UNICODE CHAR vanish.
>>
>> If that is so, why do I have to refer to double-byte unicode chars as "chars 1 - 2" ????
>
Well . . . I set up a field with "E0" followed by some Unicode like this:

set the unicodeText of fld "INN" to numToChar(69) & numToChar(48) & 
numToChar(27187)

the last being a Chinese glyph

then ran:

delete char 1 of fld "INN"    3 times  and each of those 3 chars was deleted

running this:

delete char 1 - 2 of fld "INN"   3 times did the same thing,

except backwards (i.e. it started by deleting char 27187

Nearer to enlightenment I am not . . .  :(

Setting up a further field "XT" I tried these scripts:

set the useUnicode to true
set the unicodeText of fld "XT" to the unicodeText of char 1 of fld "INN"

which plonked "E" into fld "XT" (as one might expect)

set the useUnicode to true
set the unicodeText of fld "XT" to the unicodeText of char 1 - 2 of fld 
"INN"

did nothing.

So had a try and rearranging the text in field "INN" like this:

set the unicodeText of fld "INN" to numToChar(27187) & numToChar(48) & 
numToChar(69)

and running:

set the useUnicode to true
set the unicodeText of fld "XT" to the unicodeText of char 1 of fld "INN"

No joy . . .followed by:

set the useUnicode to true
set the unicodeText of fld "XT" to the unicodeText of char 1 - 2 of fld 
"INN"

which put "E" into fld "XT"

so this is a load of old toadstools:

1. If the first char in the unicode field is a double-byte char the 
"char 1 - 2" set of
scripts work; regardless of later content.

2. If the first char (despite being in a unicode field and input using 
"set the unicodeText of fld "blahblah") is a single byte char the "char 
1 - 2" lot screw up.

3. Real toadstools because I have no way of telling if an end-user is 
going to start their screivan with a single or a double-byte char, and 
wonder if I am going to have
til gang blue in the face writing detection routine scripts anent that, 
and then further scripts depending on what "sunny Jim" screives erst.




More information about the use-livecode mailing list