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
Lazarus Release 4.0
by
WooBean
[
Today
at 01:10:44 pm]
Exceptions en FPCUnit
by
ASerge
[
Today
at 12:54:33 pm]
SnapModbus
by
bobby100
[
Today
at 12:36:45 pm]
TBitBtn no longer shows g...
by
jamie
[
Today
at 12:17:19 pm]
Output folder?
by
gues1
[
Today
at 11:59:01 am]
I created a Hello World p...
by
LV
[
Today
at 11:50:16 am]
WinInet compiling errors.
by
440bx
[
Today
at 11:21:47 am]
Firebird 5.02. - the root...
by
Nicole
[
Today
at 11:20:04 am]
Debugger fails to read da...
by
Martin_fr
[
Today
at 10:32:43 am]
Lazarus 4 - I give up and...
by
Nicole
[
Today
at 10:21:31 am]
problem with the lps
by
Nicole
[
Today
at 10:15:27 am]
issue in Lazuarus 4 - err...
by
Nicole
[
Today
at 10:10:16 am]
Classes vs Objects
by
cdbc
[
Today
at 10:09:25 am]
Strict Aliasing Rule
by
tetrastes
[
Today
at 10:04:20 am]
Hints for method name mis...
by
cdbc
[
Today
at 09:54:03 am]
mormot
by
delphi2pk
[
Today
at 09:31:05 am]
Error in inline assembly ...
by
TYDQ
[
Today
at 08:00:39 am]
[Solved] HMACSHA1Digest g...
by
Thaddy
[
Today
at 07:18:25 am]
RecordCount not working -...
by
Thaddy
[
Today
at 07:03:38 am]
LazReport: Data Inspector...
by
MaxLemberger
[
Today
at 04:03:23 am]
LAMW complaining about "A...
by
nullpointer
[
Today
at 12:52:28 am]
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]
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]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 833 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: 17178
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