vampiredom
30th December 2011, 22:38
Here is a useful function I wrote for returning to ASCII value of a character, like the reverse of chr()
Note that AviSynth seems to ignore CHR(0) in strings ... A blank string will always return 0.
# requires Gscript.dll
global __ord_ASCII__ = ""
function ord(string c) {
c = LeftStr(c,1)
Gscript("""
if (__ord_ASCII__ == "") {
for (i=1, 255, 1) {
global __ord_ASCII__ = __ord_ASCII__ + chr(i)
}
}
""")
return (c == "") ? 0 : FindStr(__ord_ASCII__, c)
}
Note that AviSynth seems to ignore CHR(0) in strings ... A blank string will always return 0.
# requires Gscript.dll
global __ord_ASCII__ = ""
function ord(string c) {
c = LeftStr(c,1)
Gscript("""
if (__ord_ASCII__ == "") {
for (i=1, 255, 1) {
global __ord_ASCII__ = __ord_ASCII__ + chr(i)
}
}
""")
return (c == "") ? 0 : FindStr(__ord_ASCII__, c)
}