Search, Replace and Unicode

Richmond richmondmathewson at gmail.com
Sat Dec 29 11:18:58 EST 2012


On 12/29/2012 05:48 PM, Richmond wrote:
> Now, of course, the real fun starts when one wants to play around with 
> wild-cards so that one can, say,
>
> swap Z and X around in a unicodeText field that contains stuff like this:
>
> ZaXddZfXabcdeZoX
>
> as I am unclear how to do that with a non-unicodeText field, the next 
> step seems a bit problematic,
> and, quite frankly, churning through 'ZaX',ZbX', 'ZcX', etc. (and I'm 
> working with an abugida that features
> about 4000 glyphs . . . joy) seems tedious in the extreme.
>
> I thought about churning through a list of unicode addresses like this;
>
> on mouseUp
> put 2200 into CLICKER
> repeat until CLICKER = 50000
>     set the useUnicode to true
>     if the unicodeText of fld "FIRST" contains (numToChar(57888) & 
> numToChar(CLICKER) & numToChar(57999)) then
>        get the unicodeText of fld "FIRST"
>        replace (numToChar(57888) & numToChar(CLICKER) & 
> numToChar(57999))) with
>       (numToChar(105) & numToChar(CLICKER) & numToChar(105)) in it
>        set the unicodeText of fld "FIRST" to it
>     end if
> add 1 to CLICKER
> end mouseUp
>
> and, theoretically, it works.
>
> the only thing that slightly fusses me about that is what happens if a 
> unicode address is empty and/or I land
> up against a control character?

This works:

doesn't seem to fuss the think whether there is a glyph present or not, 
and no problems
with any reserved chars that may be lying around somewhere within that 
range.

ran it through unicode addresses from 2325 to 62738, which took about 90 
seconds, which is rather too long, so
will cut that down to run through several ranges of unicode addresses 
rather than the whole shebang.




More information about the use-livecode mailing list