Deprecation of numToChar()

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
GS.Sunatori
Posts: 1
Joined: Fri Nov 09, 2007 3:37 am

Deprecation of numToChar()

Post by GS.Sunatori » Mon Dec 11, 2017 2:51 am

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

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

Re: Deprecation of numToChar()

Post by richmond62 » Mon Dec 11, 2017 11:09 am

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 24 times

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

Re: Deprecation of numToChar()

Post by [-hh] » Mon Dec 11, 2017 12:35 pm

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.)?
shiftLock happens

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

Re: Deprecation of numToChar()

Post by richmond62 » Mon Dec 11, 2017 12:54 pm

What -hh says is much more sensible, and less fiddly, than what I suggested. 8)

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

Re: Deprecation of numToChar()

Post by [-hh] » Mon Dec 11, 2017 1:03 pm

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.]
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5483
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Deprecation of numToChar()

Post by dunbarx » Mon Dec 11, 2017 5:19 pm

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

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 629
Joined: Fri Jun 27, 2008 9:00 pm

Re: Deprecation of numToChar()

Post by Mikey » Tue Dec 12, 2017 2:51 pm

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.

Post Reply

Return to “Talking LiveCode”