[JW Lua] FCString:CreateEnigmaStrings doesn't work on long unicode strings, but on short ones

Jan Angermüller jan at angermueller.com
Fri May 29 22:14:33 CEST 2015


Jari,

I noticed a weird problem with CreateEnigmaStrings and unicode fonts.
It occured at a forte-fortissimo created from three "f"s with the 
unicode character U+E050.

When calling FCString:CreateEnigmaStrings(true) the non-enigma commands 
were removed (!), when the string contained*3**or more* "f"s in a row. 
But they were split correctly when it were only *1 or 2* "f"s.
Below is the code (Bravura is used just for demonstration purposes,it 
holds the violin clef on U+E050, not an "f"). The first two splits work 
fine, while the next two runs return a length of zero and an empty string.
And of course, it also works fine for the non-unicode range (fifth run).
The same bug occurs if you change the unicode value to any other 
character from the widespread U+EXXX range.

Any ideas ?

All the best,
Jan

function SplitEnigma(text)
     --Create enigma strings and print all non-enigma commands (i.e. all 
texts)
     print("String to split:",text.LuaString)
     local splittext=text:CreateEnigmaStrings(true)
     for i in each(splittext) do
         if not i:IsEnigmaCommand() then
print("Len:",string.len(i.LuaString),"String:",i.LuaString)
         end
     end
end

function UnicodeToUTF(number) --unicode to UTF conversion for numbers 
between 2048 and 65535
     return string.char(bit32.bor(224,bit32.rshift(number,12))) .. 
string.char(bit32.bor(128,bit32.band(bit32.rshift(number,6),63))).. 
string.char(bit32.bor(128,bit32.band(number,63)))
end

local text=finale.FCString()
text.LuaString="^fontMus(Bravura,8192)^size(24)^nfx(0)"..UnicodeToUTF(57424)
SplitEnigma(text)
text.LuaString="^fontMus(Bravura,8192)^size(24)^nfx(0)"..UnicodeToUTF(57424)..UnicodeToUTF(57424)
SplitEnigma(text)
text.LuaString="^fontMus(Bravura,8192)^size(24)^nfx(0)"..UnicodeToUTF(57424)..UnicodeToUTF(57424)..UnicodeToUTF(57424)
SplitEnigma(text)
text.LuaString="^fontMus(Bravura,8192)^size(24)^nfx(0)"..UnicodeToUTF(57424)..UnicodeToUTF(57424)..UnicodeToUTF(57424)..UnicodeToUTF(57424)
SplitEnigma(text)
text.LuaString="^fontMus(Bravura,8192)^size(24)^nfx(0)"..string.char(123)..string.char(123)..string.char(123)..string.char(123)
SplitEnigma(text)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20150529/90bbb91c/attachment.htm>


More information about the JWLua mailing list