Re: GAS - Convert string to ascii

17 views
Skip to first unread message

Andreas Kohlbach

unread,
Apr 16, 2021, 7:25:40 PM4/16/21
to
On Fri, 16 Apr 2021 15:55:31 -0700 (PDT), Angel Lucena wrote:
>
> I want to convert "A" to ASCII, it must return 65
> I tried with "A".charCodeAt(0);
> but don't work, it said "A".charcodeAt is not a function.
> Does anyone know about the problem?

You don't say what editor and operating system. Thus I assume a
Commodore 64 (or any other 8bit computer running BASIC).

PRINT CHR$(65)

PS: ;-)
--
Andreas

Stan Brown

unread,
Apr 16, 2021, 8:31:50 PM4/16/21
to
And if your editor is Vim, use the char2nr function.
":help char2nr()" for details.

--
Stan Brown, Tehachapi, California, USA https://BrownMath.com/
https://OakRoadSystems.com/
Shikata ga nai...

Lewis

unread,
Apr 16, 2021, 9:43:29 PM4/16/21
to
In message <87o8edi...@usenet.ankman.de> Andreas Kohlbach <a...@spamfence.net> wrote:
> On Fri, 16 Apr 2021 15:55:31 -0700 (PDT), Angel Lucena wrote:
>>
>> I want to convert "A" to ASCII, it must return 65
>> I tried with "A".charCodeAt(0);

var charCode = "a".charCodeAt(0);

That definitely works in JavScript.

>> but don't work, it said "A".charcodeAt is not a function.
>> Does anyone know about the problem?

> You don't say what editor and operating system. Thus I assume a
> Commodore 64 (or any other 8bit computer running BASIC).

> PRINT CHR$(65)

For bash:

printf '%d' "'A'"

php:

ord("A");


--
Marriages made in heaven are not exported.

Fred Weigel

unread,
May 13, 2021, 12:00:23 PM5/13/21
to
Being comp.editors, and I want some fun with editing:

PMATE editor:

"A$$ yields ARG=65 ($ is esc key)
"A\$$ inserts "65" into current edit buffer
65i$$ inserts "A" into current edit buffer

so

"Ai$$ also inserts "A" into current edit buffer.

16qo"A\10qo$$ would insert "41" as we have shifted to base-16 and back to base-10

How about

iA$-M@t$$ yields ARG=65

this one works by inserting "A" into current buffer, backing up to it, and then fetching
the edit buffer character.

Yes, PMATE is a TECO variant.
Reply all
Reply to author
Forward
0 new messages