A char2num function that works for ASCII codes 0-->255.
andyfaff
i.e. one gets around the problem:
print char2num(num2char(56))
56
print char2num(num2char(249))
-7
print num2char(249)
ÿ
56
print char2num(num2char(249))
-7
print num2char(249)
ÿ
Function extendedASCIIchar2num(chars)
string chars
make/o/t/n=(strlen(chars),2) W_chartranslation
variable ii,decChar
for(ii=0 ; ii < strlen(chars) ; ii+=1)
W_chartranslation[ii][0] = chars[ii]
decChar = char2num(chars[ii])
if( 0 <= decChar && decChar <= 127)
W_chartranslation[ii][1] = num2istr(decChar)
else
W_chartranslation[ii][1]= num2istr(255 + decChar + 1)
endif
endfor
End
string chars
make/o/t/n=(strlen(chars),2) W_chartranslation
variable ii,decChar
for(ii=0 ; ii < strlen(chars) ; ii+=1)
W_chartranslation[ii][0] = chars[ii]
decChar = char2num(chars[ii])
if( 0 <= decChar && decChar <= 127)
W_chartranslation[ii][1] = num2istr(decChar)
else
W_chartranslation[ii][1]= num2istr(255 + decChar + 1)
endif
endfor
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More