Hi,

I'd like to specify the string of ASCII chars, codes of which I know.

CString str = "\13" + "\10" + "\25";

^^
does not work :(

Neither works
CString str = _T("\13\10\25");

What are the possible and preferred ways to do that?

Re: string of ascii chars? by Heinz

Heinz
Thu Jul 15 06:02:09 CDT 2004

"Andru" <andru123 at hotmail dot com> schrieb im Newsbeitrag =
news:uLXQy8kaEHA.712@TK2MSFTNGP11.phx.gbl...
> Hi,
>=20
> I'd like to specify the string of ASCII chars, codes of which I know.
>=20
> CString str =3D "\13" + "\10" + "\25";
>=20
> ^^
> does not work :(

You cannot add pointers.

>=20
> Neither works
> CString str =3D _T("\13\10\25");
>=20
> What are the possible and preferred ways to do that?

Do what? The last line of code does work and initializes str with a =
string of characters 0x0B, 0x08 and 0x15. Numbers following \ in a =
string or char literal are octal. If you want a string starting with =
carriage return and linefeed you should write "\x0D\x0A..." or =
"\15\12..." or "\r\n...".

HTH
Heinz

Re: string of ascii chars? by Andru

Andru
Thu Jul 15 08:24:13 CDT 2004


"Heinz Ozwirk" <wansor42@gmx.de> wrote in message
news:cd5o5d$p4b$04$1@news.t-online.com...

>Do what? The last line of code does work and initializes str with a string
of characters 0x0B, 0x08 and 0x15. Numbers following \ in a string or char
literal are octal. If you want a string starting with carriage return and
linefeed you should write "\x0D\x0A..." or "\15\12..." or "\r\n...".


^^ Unfortunately it initializes it to a string "\13\10\25" - exactly as you
see it (9 chars).




Re: string of ascii chars? by David

David
Thu Jul 15 09:13:04 CDT 2004


"Andru" <andru123 at hotmail dot com> wrote in message
news:%23pePE8maEHA.2340@TK2MSFTNGP09.phx.gbl...

> "Heinz Ozwirk" <wansor42@gmx.de> wrote in message
> news:cd5o5d$p4b$04$1@news.t-online.com...
>
> >Do what? The last line of code does work and initializes str with
a string
> of characters 0x0B, 0x08 and 0x15. Numbers following \ in a string
or char
> literal are octal. If you want a string starting with carriage
return and
> linefeed you should write "\x0D\x0A..." or "\15\12..." or
"\r\n...".
>
> ^^ Unfortunately it initializes it to a string "\13\10\25" -
exactly as you
> see it (9 chars).

Octal constants start with a leading zero, just as hexadecimal ones
start with 0x. You therefore need

"\015\012"

to get characters number thirteen and ten.

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm



Re: string of ascii chars? by Igor

Igor
Thu Jul 15 09:45:50 CDT 2004

"David Webber" <dave@musical.demon.co.uk> wrote in message
news:%23eWsgXnaEHA.2932@TK2MSFTNGP10.phx.gbl
> Octal constants start with a leading zero, just as hexadecimal ones
> start with 0x.

Integral constants, yes, but not character escape sequences. Octal
escape sequence does not need a leading 0 (but may have one). '\15' is a
valid character with code 015 == 13 == 0xD. Hex escape sequence starts
with \x, not \0x, so the same character can be written as '\xD'
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Re: string of ascii chars? by Igor

Igor
Thu Jul 15 09:49:12 CDT 2004

"Andru" <andru123 at hotmail dot com> wrote in message
news:%23pePE8maEHA.2340@TK2MSFTNGP09.phx.gbl
> "Heinz Ozwirk" <wansor42@gmx.de> wrote in message
> news:cd5o5d$p4b$04$1@news.t-online.com...
>
>> Do what? The last line of code does work and initializes str with a
>> string
> of characters 0x0B, 0x08 and 0x15. Numbers following \ in a string or
> char literal are octal. If you want a string starting with carriage
> return and linefeed you should write "\x0D\x0A..." or "\15\12..." or
> "\r\n...".
>
>
> ^^ Unfortunately it initializes it to a string "\13\10\25" - exactly
> as you see it (9 chars).

What makes you think so? Are you perhaps looking at the string in
debugger, which of course displays the string following C syntax, with
escape sequences in place? What's the value of str.GetLength() after the
assignment str = _T("\13\10\25") ? Can you show a small compilable
program that demonstrates the problem?
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Re: string of ascii chars? by Andru

Andru
Thu Jul 15 10:10:06 CDT 2004

> What makes you think so? Are you perhaps looking at the string in
> debugger, which of course displays the string following C syntax, with
> escape sequences in place? What's the value of str.GetLength() after the
> assignment str = _T("\13\10\25") ? Can you show a small compilable
> program that demonstrates the problem?
> --

I was incorrect. I accidentally used forward slash, so the string returned
by _T("/13/10") really was "/13/10".

:(



Re: string of ascii chars? by David

David
Fri Jul 16 12:22:28 CDT 2004


"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:uUbNtpnaEHA.4092@TK2MSFTNGP11.phx.gbl...

> Integral constants, yes, but not character escape sequences. Octal
> escape sequence does not need a leading 0 (but may have one).
'\15' is a
> valid character with code 015 == 13 == 0xD. Hex escape sequence
starts
> with \x, not \0x, so the same character can be written as '\xD'

Thank you - I have always used the leading zero in all cases, and
must have simply assumed it was always necessary in the escape
sequence. This appeared to have been confirmed - until Andru
confessed to using a forward slash :-).

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm