Error with Unicode characters?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Error with Unicode characters?

Post by danielrr » Sun Oct 27, 2019 12:42 pm

I feel sometimes Live code doesnt treat Unicode characteres as it should. Here's an example. Vocals with acute accent have different codepoints for Modern Greek (monotonic) and ancient Greek (polytonic). That means, the same pair of accented vowel and acute accent has two different encodings.
The correspondence is as follows

monotonic 940 = polytonic 8049
monotonic 941 = polytonic 8051
monotonic 942 = polytonic 8053
monotonic 943 = polytonic 8055
monotonic 972 = polytonic 8057
monotonic 973 = polytonic 8059
monotonic 974 = polytonic 8061

Now, if you want to convert the monotonic characters into the corresponding polytonic version, you may think this would do the job:

Code: Select all

 
   put "940,941,942,943,972,973,974" into vi
   put "8049,8051,8053,8055,8057,8059,8061" into nu
   put 0 into x
   repeat for each item elViejo in vi
      add 1 to x
      put item x of nu into elNuevo
      put the numtocodepoint of elViejo into monotonic
      put the numtocodepoint of elNuevo into polytonic
      repeat while monotonic is in container
         put polytonic into char offset(monotonic,container) of container
      end repeat
   end repeat
   
Alas, if you try this script with a text with monotonic-accented characters, you get into a infinite loop. Why is it? Am I missing something?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Error with Unicode characters?

Post by richmond62 » Sun Oct 27, 2019 1:38 pm

I don't understand much about this, but THIS did something:

Code: Select all

on mouseUp
   put empty into fld "fOUTPUT"
   put "940,941,942,943,972,973,974" into vi
   put "8049,8051,8053,8055,8057,8059,8061" into nu
   put 1 into xx
   repeat for each item zz in vi
      add 1 to xx
      put numToCodePoint(zz) && "|" into line xx of fld "fOUTPUT"
   end repeat
   put 1 into ww
   repeat for each item zz in nu
      add 1 to ww
      put " " & numToCodePoint(zz) after line ww of fld "fOUTPUT"
   end repeat
end mouseUp
-
Monotone.png
-
I hope that is some help.
Attachments
Monotony.livecode.zip
Here's the stack.
(1.16 KiB) Downloaded 154 times

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Error with Unicode characters?

Post by [-hh] » Sun Oct 27, 2019 2:34 pm

You could try

Code: Select all

put "940,941,942,943,972,973,974" into vi
put "8049,8051,8053,8055,8057,8059,8061" into nu
repeat with i=1 to 7
  replace numtocodepoint(item i of vi) with \
        numtocodepoint(item i of nu) in container
end repeat
[Using "offset" with unicode text bears problems.]
shiftLock happens

danielrr
Posts: 140
Joined: Mon Mar 04, 2013 4:03 pm

Re: Error with Unicode characters?

Post by danielrr » Sun Oct 27, 2019 8:27 pm

thanks, Richmond, -hh! :D

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”