View Full Version : ASCII problem..... please help A.S.A.P
solal
11-23-2002, 07:58 AM
what is the function name to convert a letter/number/etc..
to a Ascii code?
and the opposite: ascii code to a letter/number/etc...?
if you know, in PASCAL the functions are Ord and Chr, like this:
y:=ORD(num);
y:=CHR(num);
so what's the equilevant in JavaScript?
joh6nn
11-23-2002, 08:52 AM
var y = String.fromCharCode(32); // a space
var y = y.charCodeAt(0); // returns the unicode value of the character at place 0 ( the first place ) in the string y
solal
11-23-2002, 08:19 PM
that's not what i need!
i need the ORD & CHR like in Pascal!
but in java!
joh6nn
11-23-2002, 09:13 PM
please reply in the original thread, not in a new one.
and yes, that is what you need, unless you didn't explain yourself as clearly as you meant to. i don't know Pascal, so i've no idea what ORD and CHR, though i could guess. but i do know JavaScript, and quite well, i like to think, and i know that
var y = String.fromCharCode(num)
will return the character for whatever ascii number num is, and i know that
var y = y.charCodeAt(num)
will take a string, and tell you what the ascii code for the character at num is.
krycek
11-24-2002, 12:40 AM
joh6nn is completely right.
the functions he has told you are the exact javascript equivalents of ORD and CHR. I suggest you are not using them properly!
Also, we DID answer this in your last thread... and I know joh6nn has already said it once, but what is the point of posting another thread with the same question? :S
::] krycek [::
joh6nn
11-24-2002, 03:04 AM
in light of the fact that 1) this thread is a duplicate of your other thread, and 2) you got the answer yesterday, i'm closing the thread.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.