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
Free Pascal ncurses TUI
by
Gustavo 'Gus' Carreno
[
Today
at 12:29:16 am]
[SOLVED] Strange result (...
by
tfurnivall
[June 21, 2025, 11:24:05 pm]
SnapModbus
by
bobby100
[June 21, 2025, 11:09:58 pm]
InstallAware 2025 Sources...
by
n7800
[June 21, 2025, 10:44:56 pm]
WinInet compiling errors.
by
440bx
[June 21, 2025, 10:07:14 pm]
Lazarus Release 4.0
by
JuhaManninen
[June 21, 2025, 09:35:05 pm]
How to fix "Warning: Enco...
by
ecm
[June 21, 2025, 09:20:42 pm]
BGRA Controls
by
alan1076
[June 21, 2025, 09:06:37 pm]
Classes vs Objects
by
TBMan
[June 21, 2025, 08:23:08 pm]
[SOLVED] RecordCount not ...
by
1HuntnMan
[June 21, 2025, 07:57:58 pm]
How to read shortstring f...
by
Thaddy
[June 21, 2025, 07:32:43 pm]
What WinAPI functions can...
by
Tikani93
[June 21, 2025, 07:19:20 pm]
Fast Canvas Library V1.0
by
Gigatron
[June 21, 2025, 07:07:54 pm]
Opencv version 4.6 C++ AP...
by
gidesa
[June 21, 2025, 06:55:53 pm]
Hints for method name mis...
by
JuhaManninen
[June 21, 2025, 05:36:46 pm]
Debugger fails to read da...
by
Martin_fr
[June 21, 2025, 04:48:12 pm]
Error: Identifier not fou...
by
Thaddy
[June 21, 2025, 04:30:14 pm]
X11Libre, finally and for...
by
Fred vS
[June 21, 2025, 04:07:05 pm]
Strict Aliasing Rule
by
nixbody
[June 21, 2025, 03:20:29 pm]
opinion on outlining text...
by
jamie
[June 21, 2025, 03:17:00 pm]
TBitBtn no longer shows g...
by
jamie
[June 21, 2025, 03:05:19 pm]
problem with the lps
by
n7800
[June 21, 2025, 01:52:07 pm]
Exceptions en FPCUnit
by
ASerge
[June 21, 2025, 12:54:33 pm]
Output folder?
by
gues1
[June 21, 2025, 11:59:01 am]
I created a Hello World p...
by
LV
[June 21, 2025, 11:50:16 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED] Ascii code to string (Read 835 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: 17187
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