Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Ascii code to string
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
LazReport: Data Inspector...
by
MaxLemberger
[
Today
at 04:03:23 am]
Hints for method name mis...
by
dsiders
[
Today
at 03:56:15 am]
Exceptions en FPCUnit
by
ASerge
[
Today
at 02:52:22 am]
Classes vs Objects
by
TBMan
[
Today
at 02:43:06 am]
LAMW complaining about "A...
by
nullpointer
[
Today
at 12:52:28 am]
Firebird 5.02. - the root...
by
incendio
[
Today
at 12:27:38 am]
problem with the lps
by
wp
[
Today
at 12:26:24 am]
WinInet compiling errors.
by
marcov
[June 20, 2025, 11:57:17 pm]
How to export Pascal vari...
by
ecm
[June 20, 2025, 11:38:24 pm]
Layout problem by nested ...
by
Martin_fr
[June 20, 2025, 10:29:38 pm]
Lazarus 4 - I give up and...
by
Martin_fr
[June 20, 2025, 10:23:23 pm]
IBX installing - packages...
by
Nicole
[June 20, 2025, 10:16:20 pm]
Status and Maintenance of...
by
hdb
[June 20, 2025, 10:09:45 pm]
Documentation
by
LemonParty
[June 20, 2025, 10:03:21 pm]
Strict Aliasing Rule
by
nixbody
[June 20, 2025, 10:01:29 pm]
RecordCount not working -...
by
CharlyTango
[June 20, 2025, 09:43:24 pm]
IBX 2.7.2, What's wrong w...
by
rvk
[June 20, 2025, 09:33:54 pm]
InstallAware 2025 Sources...
by
msintle
[June 20, 2025, 08:29:41 pm]
Animation demo with multi...
by
TBMan
[June 20, 2025, 06:25:26 pm]
I created a Hello World p...
by
Weiss
[June 20, 2025, 05:25:28 pm]
[SOLVED] LAMW - UTF-8 cha...
by
Alcatiz
[June 20, 2025, 05:08:51 pm]
[Solved] HMACSHA1Digest g...
by
fedkad
[June 20, 2025, 04:41:07 pm]
TBitBtn no longer shows g...
by
Awesome Programmer
[June 20, 2025, 04:38:15 pm]
SnapModbus
by
Thaddy
[June 20, 2025, 03:18:55 pm]
mormot
by
Thaddy
[June 20, 2025, 03:01:26 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 832 times)
CM630
Hero Member
Posts: 1404
Не съм сигурен, че те разбирам.
[SOLVED] Ascii code to string
«
on:
May 23, 2025, 08:35:22 am »
Oddly, I cannot find the answer.
I need to convert an ASCII code to a string.
In other words, I need to convert the number $48 to the string 'H'. How?
«
Last Edit: May 23, 2025, 08:43:37 am by CM630
»
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Fibonacci
Hero Member
Posts: 754
Internal Error Hunter
Re: Ascii code to string
«
Reply #1 on:
May 23, 2025, 08:37:28 am »
https://www.freepascal.org/docs-html/rtl/system/chr.html
or
Code: Pascal
[Select]
[+]
[-]
str
:
=
#
$48
;
Logged
CM630
Hero Member
Posts: 1404
Не съм сигурен, че те разбирам.
Re: [SOLVED] Ascii code to string
«
Reply #2 on:
May 23, 2025, 08:44:23 am »
Thanks, this seems to work:
Code: Pascal
[Select]
[+]
[-]
String
(
#
$48
)
or
Code: Pascal
[Select]
[+]
[-]
String
(
char
(
$48
)
)
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Thaddy
Hero Member
Posts: 17176
Ceterum censeo Trump esse delendam
Re: [SOLVED] Ascii code to string
«
Reply #3 on:
May 23, 2025, 12:44:46 pm »
The casts are not necessary. That puts people on the wrong foot imho.
Code: Pascal
[Select]
[+]
[-]
{$mode objfpc}
begin
writeln
(
#
$48
)
;
// this is already a string in hex notation: H.
end
.
Logged
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
CM630
Hero Member
Posts: 1404
Не съм сигурен, че те разбирам.
Re: [SOLVED] Ascii code to string
«
Reply #4 on:
May 23, 2025, 09:47:01 pm »
Indeed. Both line result in
H
.
Code: Pascal
[Select]
[+]
[-]
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
i
:
byte
=
$48
;
begin
ShowMessage
(
String
(
char
(
i
)
)
)
;
ShowMessage
(
char
(
i
)
)
;
end
;
Logged
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
[SOLVED] Ascii code to string
TinyPortal
© 2005-2018