Page 1 of 1

Deprecation of numToChar()

Posted: Mon Dec 11, 2017 2:51 am
by GS.Sunatori
My simple handler below had been working fine for more than a decade, but it broke when numToChar() was deprecated. Changing it to numToNativeChar() or numToCodepoint() does not do the same thing, so it remains broken. Any suggestion to restore the functionality would be greatly appreciated. Thank you!

function MakeClip tClip
set itemDel to ","
put \
"145,39" & return & \
"146,39" & return & \
"147,34" & return & \
"148,34" & return & \
"150,45" & return & \
"151,45" & return & \
"202,32" & return & \
"208,45" & return & \
"209,45" & return & \
"210,34" & return & \
"211,34" & return & \
"212,39" & return & \
"213,39" into tTable
repeat for each line tLine in tTable
replace numToChar(item 1 of tLine) with numToChar(item 2 of tLine) in tClip
end repeat
return tClip
end MakeClip

Re: Deprecation of numToChar()

Posted: Mon Dec 11, 2017 11:09 am
by richmond62
I'm not entirely sure if this will help: it's something I dreamt up during
my lunch break:
EXCHANGE.jpg
Test.livecode.zip
(1.25 KiB) Downloaded 262 times

Re: Deprecation of numToChar()

Posted: Mon Dec 11, 2017 12:35 pm
by [-hh]
Possibly the problem is not numToChar but that your input text encoding changed.

If you switched to UTF-8 then your high bit (> 127) chars may have now a different code.

Why don't you simply use a 'direct' char replacement (replace "‘" with "'" etc.)?

Re: Deprecation of numToChar()

Posted: Mon Dec 11, 2017 12:54 pm
by richmond62
What -hh says is much more sensible, and less fiddly, than what I suggested. 8)

Re: Deprecation of numToChar()

Posted: Mon Dec 11, 2017 1:03 pm
by [-hh]
No.

NumToCodePoint is the replacement for numToChar when using Unicode text (if really needed, for example with the famous DevaWriter). For UTF-8 input LC 8/9 usually doesn't require any transformations.

[And for images we can use numToByte instead.]

Re: Deprecation of numToChar()

Posted: Mon Dec 11, 2017 5:19 pm
by dunbarx
The numToChar and charToNum have been deprecated. But they still work in v.8. This has caused confusion.

If one is not concerned with unicode, then those two functions can continue to be used without issue. Whether or not this is prudent and forward looking is another story.

Craig Newman

Re: Deprecation of numToChar()

Posted: Tue Dec 12, 2017 2:51 pm
by Mikey
I didn't realize they had been deprecated. It would be good to have a legacy library for those deprecated features that might still appear in our projects. Then it isn't part of the core product, but we can still use them, perhaps with a warning.