Inserting unicodeText into a unicode string? #3

Richmond richmondmathewson at
Mon Aug 30 06:22:53 EDT 2010

  On 8/29/10 10:35 PM, Mark Schonewille wrote:
> Richmond,
> Unfortunately, it is slightly more complicated. Before you set the unicodeText of the selectedText, you need to make sure that the number of chars before the text insertion point is even. If it isn't, you need to move the text insertion point by one position. Once you've done that, you should be able to set the unicodeText relatively crash-less ;-) Be careful, as the selectedChunk can be confusing. If the selection itself is empty, you would see something like this:
> char 10 to 9 of field 2
> The second number is the number of characters before the text insertion point. Here's an example that moves the text insertion point forward:
> on mouseUp
>       if the selectedChunk is not empty then
>            put the selectedChunk into myChunk
>            add 1 to word 2 of myChunk
>            add 1 to word 4 of myChunk
>            select myChunk
>       end if
> end mouseUp
> The script is not complete. It doesn't check whether it has run out of chunks.
This is a very cogent point.

HOWEVER; it seems that unicode numToChar(32) [ 'SPACE' ] is a single 
byte figure, so,
for the sake of argument, examining what char precedes an insertion 
point means that, first, one has
to find out whether it is a single or a double byte figure: somewhat tricky.

More information about the Use-livecode mailing list