From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-07-12 08:21:08
Hi!
On Fri, Jul 12, 2002 at 02:47:31AM +0200, MagerValp wrote:
> I started porting the Serial Slave tools to C (the tools need a
> rewrite), and I ran into a weird issue with cr and lf:
>
> if (sendstring("<$\r\n") != OK) {
> return(ERROR);
> }
>
> gives me 3c 24 0a 0d 00 as the string. Fair enough. So I changed it to
>
> if (sendstring("<$\x0d\x0a") != OK) {
> return(ERROR);
> }
>
> but that also gave me 3c 24 0a 0d 00 as the string. Surely, this can't
> be right? Oh well, \n\r works, but it looks weird...
All string literals get translated to the target character set - this is what
one would expect from the compiler. You would expect the '<' and '$' in the
same string to be converted into PETSCII, wouldn't you?
If you don't want translation, either use "-t none", or don't use string
literals:
const char cmd[] = { 0x3C, 0x24, 0x0D, 0x0A, 0x00 };
Since there is also a translation for character constants, you can use this
method also if you need mixed (partially translated) strings:
const char cmd[] = { '<', '$', 0x0D, 0x0A, 0x00 };
In this case, the first two characters get translated, but the last three will
not.
Regards
Uz
--
Ullrich von Bassewitz uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-07-12 08:21:38 CEST