Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!fernwood!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: two chars at once... Message-ID: <14639@haddock.ima.isc.com> Date: 19 Sep 89 00:10:31 GMT References: <11057@smoke.BRL.MIL> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 23 In article <11057@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article sr16+@andrew.cmu.edu (Seth Benjamin Rothenberg) writes: >>One of the nasty things it does is treat 2 characters >>as a single 2-byte integer. >> if "ax" = mystr -> if mystr[1]=>C1D9 (or something like that) > >The direct equivalent in C would be to use multi-character character >constants such as 'AX', which [contain both characters in an implementation- >dependent manner]. Using 2-character strings would be more portable (Terminology: since X3J11 has already claimed the words "multibyte character"% and "wide character"&, and neither one of them refers to the construct above, I have taken to calling them "siamese character constants".) If the inefficiency of using two-character strings is a problem, and you don't want to rely on the properties (or even the existence) of siamese character constants, you can replace them with a macro: #define two(a,b) (((a)<