Wanted: idiot's guide to using Unicode in Rev

Kenji Kojima index at kenjikojima.com
Wed Dec 8 10:40:01 EST 2004


Ben,

Convert the whole field ascii to unicode.
Maybe this is the one of workarounds.
AsciiToUni was made by Kiyoshi Kamogawa.

on asciiToUni pFldName, pLang
   if pLang is "" then
     put ",japanese" into pLang
   end if
   put number of lines of fld pFldName into tNumOfLines
   lock screen
   repeat with i=1 to tNumOfLines
     put 0 into tNumOfChars
     repeat with h=1 to (number of chars of line i of fld pFldName)
       if (textFont of char h of line i of fld pFldName) contains "," 
then
         put tNumOfChars + 2 into tNumOfChars
         put h + 1 into h
       else
         put tNumOfChars + 2 into tNumOfChars
       end if
     end repeat
     repeat with j=1 to tNumOfChars
       if (textFont of char j of line i of fld pFldName) contains "," 
then
         put j + 1 into j
       else
         set useUnicode to true
         put uniEncode(char j of line i of fld pFldName) into tUniChar
         put tUniChar into char j of line i of fld pFldName
         set textFont of char j to j+1 of line i of fld pFldName to pLang
         set useUnicode to false
         put j+1 into j
       end if
     end repeat
   end repeat
end asciiToUni

--
Kenji Kojima
http://www.kenjikojima.com/


On 2004/12/08, at 9:11, Ben Rubinstein wrote:

> Thanks to Ron Barber for some helpful responses to my previous mail.  
> I'm
> making very slow and stumbling progress - still, progress!  Now I've 
> hit
> another area in which my incomprehension may be mixing with Rev bugs.
>
> Working with a field which has interited Geneva as it's font. Set the
> htmltext of a field to some text with a unicode character, eg
>     <p>Hell<font lang="el">ō</font>, world.</p><p>Goodbye.</p>
>
> Expected is a single unicode character (o-macron), in otherwise English
> text, ie
>         Hell<o-macron>, world.
>         Goodbye.
>
> Result is that all the text from the unicode character to the end of 
> the
> paragraph is displayed as Japanese characters, ie
>         Hell<o-macron><japananese characters>
>         Goodbye.
>
> I can construct the desired behaviour by inserting the character after 
> the
> rest of the text has been set; that is, first I set the field to the 
> text
>         Hello, world.
>         Goodbye.
>
> then execute the statements
>     put "<font lang=" & quote & "el" & quote & ">ō</font>" into x
>     set the htmlText of char 5 of fld 1 to x
>
> Then I get the desired appearance.  I then ask for the htmlText of the 
> whole
> field, I get the string I started with, that is
>     <p>Hell<font lang="el">ō</font>, world.</p><p>Goodbye.</p>
>
> In other words, setting the htmlText of the field to the htmlText of 
> the
> field changes it (rendering all the characters after the o-macron to
> japanese characters. Is this a bug?  Is it a known bug?  Is it in 
> bugzilla?
> Is there a workaround?
>
> Note that the same does not occur with unicodeText - eg given a field
> constructed as above, the statement
>     set the unicodeText of fld 1 to the unicodeText of fld 1
>
> doesn't change the text (but of course it does change any style 
> attributes,
> so this isn't by itself a solution to my problem.)
>
> Also note, attempted workaround: explicitly changing the font of the 
> next
> character works, ie setting the field to:
>
>     <p>Hell<font lang="el">ō</font><font language="en">,</font>
> world.</p><p>Goodbye.</p>
>
> so forcing the comma that immediately follows o-macron back to english
> works; but this isn't a great solution in my general case, as the next
> character might be anything - a plain character, another unicode 
> entity, the
> opening of another markup tag.  Coding for the general case would be a 
> real
> PITA.  (I also tried just using the font tags without enclosing a 
> character,
> that is
>
>     <p>Hell<font lang="el">ō</font><font language="en"></font>,
> world.</p><p>Goodbye.</p>
>
> Sadly this didn't work!
>
> Any help, tips, pointers to documentation, or answers to the specific
> questions above would be very gratefully received.
>
>
>   Ben Rubinstein               |  Email: benr_mc at cogapp.com
>   Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
>   http://www.cogapp.com        |  Fax  : +44 (0)1273-728866
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>







More information about the use-livecode mailing list