Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Generar un string con codigos ascii (https://www.clubdelphi.com/foros/showthread.php?t=65440)

JordiP 15-12-2009 12:49:47

Generar un string con codigos ascii
 
Buenas, tengo un problema intentando crear un string con códigos ASCII. Veréis, tengo un array de Bytes los cuales quiero convertir en sus respectivos símbolos ASCII. Cuando intento convertir ciertos códigos, como el 24 por ejemplo, en vez de ponerme en el string, pone #&18, por ejemplo: tengo que generar el siguiente string:

Código Delphi [-]
Mi_string := Chr(40) + Chr(24) + Chr(43);


[/font][/size]
Pues esto deberia tener como resultado '(↑+', pero lo que obtengo es '('#&18'+'

Mi pregunta es: cual es la mejor manera de obtener '(↑+' con Delphi ?

Gracias por todo y espero que alguien me pueda ayudar.

Neftali [Germán.Estévez] 15-12-2009 14:29:57

¿Con qué versión de Delphi trabajas?
¿Dónde has visto ese valor?

Coloca debajo este código:

Código Delphi [-]
  Edit1.Text := Chr(40) + Chr(24) + Chr(43);

Y a la propiedad Font/CharSet del edit1 asignale OEM_CHARSET.

¿Qué se ve en el Edit?

Ñuño Martínez 15-12-2009 14:31:04

El código ASCII 24 es un código de control, esto es, no imprimible; concretamente se corresponde con la orden "Cancelar". ASCII "esctricto" no dispone de un caracter "Flecha arriba". Tal vez en alguna de las páginas extendidas exista ese símbolo, pero no lo encuentro.

sergiovalp 15-12-2009 14:40:41

en ANSI el caracter 24 no lo puedes representar, es de tipo reservado.


The Ansi character set Char Code Description

9 Tab
10 Line feed
13 Carriage return
' ' 32 Space
! 33 Exclamation mark
" 34 Quotation mark
# 35 Number sign
$ 36 Dollar sign
% 37 Percent sign
& 38 Ampersand
' 39 Apostrophe
( 40 Left parenthesis
) 41 Right parenthesis
* 42 Asterisk
+ 43 Plus sign
, 44 Comma
- 45 Hyphen-minus
. 46 Full stop
/ 47 Solidus
0 48 Digit zero
1 49 Digit one
2 50 Digit two
3 51 Digit three
4 52 Digit four
5 53 Digit five
6 54 Digit six
7 55 Digit seven
8 56 Digit eight
9 57 Digit nine
: 58 Colon
; 59 Semicolon
< 60 Less-than sign
= 61 Equals sign
> 62 Greater-than sign
? 63 Question mark
@ 64 Commercial at
A 65 Latin capital letter A
B 66 Latin capital letter B
C 67 Latin capital letter C
D 68 Latin capital letter D
E 69 Latin capital letter E
F 70 Latin capital letter F
G 71 Latin capital letter G
H 72 Latin capital letter H
I 73 Latin capital letter I
J 74 Latin capital letter J
K 75 Latin capital letter K
L 76 Latin capital letter L
M 77 Latin capital letter M
N 78 Latin capital letter N
O 79 Latin capital letter O
P 80 Latin capital letter P
Q 81 Latin capital letter Q
R 82 Latin capital letter R
S 83 Latin capital letter S
T 84 Latin capital letter T
U 85 Latin capital letter U
V 86 Latin capital letter V
W 87 Latin capital letter W
X 88 Latin capital letter X
Y 89 Latin capital letter Y
Z 90 Latin capital letter Z
[ 91 Left square bracket
\ 92 Reverse solidus
] 93 Right square bracket
^ 94 Circumflex accent
_ 95 Low line
` 96 Grave accent
a 97 Latin small letter a
b 98 Latin small letter b
c 99 Latin small letter c
d 100 Latin small letter d
e 101 Latin small letter e
f 102 Latin small letter f
g 103 Latin small letter g
h 104 Latin small letter h
i 105 Latin small letter i
j 106 Latin small letter j
k 107 Latin small letter k
l 108 Latin small letter l
m 109 Latin small letter m
n 110 Latin small letter n
o 111 Latin small letter o
p 112 Latin small letter p
q 113 Latin small letter q
r 114 Latin small letter r
s 115 Latin small letter s
t 116 Latin small letter t
u 117 Latin small letter u
v 118 Latin small letter v
w 119 Latin small letter w
x 120 Latin small letter x
y 121 Latin small letter y
z 122 Latin small letter z
{ 123 left curly bracket
| 124 Vertical line
} 125 Right curly bracket
~ 126 Tilde
 127 (not used)

Neftali [Germán.Estévez] 15-12-2009 18:27:27

Bueno, yo me refería a esto; Que dependiendo de la representación que se escoja, tal vez sí se puedan ver esos caracteres como él desea, aunque no se si es lo que quiere conseguir.


sergiovalp 15-12-2009 19:22:17

al menos en delphi 4 y 6 no es posible, incluso cambiando la representación.

bosster_018 16-12-2009 04:15:46

No sale
 
...............

bosster_018 16-12-2009 04:16:48

No sale
 
Cita:

Empezado por Neftali (Mensaje 348852)
¿Con qué versión de Delphi trabajas?
¿Dónde has visto ese valor?

Coloca debajo este código:

Código Delphi [-]
  Edit1.Text := Chr(40) + Chr(24) + Chr(43);


Y a la propiedad Font/CharSet del edit1 asignale OEM_CHARSET.

¿Qué se ve en el Edit?


Mala suerte... No me sale tampoco a mí :rolleyes::

(□+

Me sale un simbolo sin valor alguno, a pesar de cambiar la propiedad Font/Charset del edit

Por si acaso también probé usando todas las opciones que había en la propiedad Font/Charset del edit

Neftali [Germán.Estévez] 16-12-2009 09:18:18

Efectívamente, sólo en las nuevas versiones de Delphi es posible conseguirlo de esta forma, de ahí mi pregunta.

JordiP 16-12-2009 11:39:16

Pues si ya lo he probado con un TEdit y me pone el simbolo correcto, pero no logro hacerlo concatenando strings, es decir:

Código Delphi [-]
mi_string:=Chr(40) + Chr(24) + Chr(43);
De todas maneras, he hecho una chapucilla y es generarme una funcion que pasando el codigo, retorna el correspondiente simbolo ascii.


Nuevamente gracias a todos por la ayuda.


La franja horaria es GMT +2. Ahora son las 04:10:50.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi