Continued Help with Unicode Text
Dan Friedman
dan at clearvisiontech.com
Tue Mar 29 15:55:46 EST 2005
Hello again...
I've been fiddling with this for days now. If you remember, my goal was to
save unicode text in a single line - while preserving returns. This is the
only way I could get it to work. Obviously, this creates a larger file on
disk. Do you see any problems with this method that will kill me down the
road? Do you see a better way to do this?
-- save the unicode text from a field to a file
set the useUnicode to true
put field 2 into jText --contains single or multi-lingual text
put 0 into L
put 1 into charNum
repeat until charNum > the number of chars in jText
add 1 to L
if char charNum of jText = cr then
put "<cr>" into item L of textToWrite
add 1 to charNum
else
put charToNum(char charNum to charNum+1 of jText) into \
item L of textToWrite
add 2 to charNum
end if
end repeat
put textToWrite into url ("file:/Users/aUser/Desktop/jappTest2.txt")
-- read the file and restore the text
put url ("file:/Users/aUser/Desktop/jappTest2.txt") into tText
set the useUnicode to true
repeat for each item tChar in tText
if tChar = "<cr>" then
put numToChar(10) after jText
else
put numToChar(tChar) after jText
end if
end repeat
set the unicodeText of field 2 to jText
More information about the use-livecode
mailing list