Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: detecting ASCII/EBCDIC

Reply
Thread Tools

Re: detecting ASCII/EBCDIC

 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      09-03-2008
On Sep 3, 7:41 am, Pilcrow <(E-Mail Removed)> wrote:
> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <(E-Mail Removed)> wrote:
> >Is there a way that a proram can detect whether it is operating in an
> >ASCII or an EBCDIC environment?

>
> OK, it seems I have my answer: if('i' + 1 != 'j') we definitely don't


That expression invokes undefined behavior if 'i' equals INT_MAX.

<snip>

 
Reply With Quote
 
 
 
 
Harald van Dijk
Guest
Posts: n/a
 
      09-03-2008
On Tue, 02 Sep 2008 21:49:51 -0700, vippstar wrote:
> On Sep 3, 7:41 am, Pilcrow <(E-Mail Removed)> wrote:
>> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <(E-Mail Removed)> wrote:
>> >Is there a way that a proram can detect whether it is operating in an
>> >ASCII or an EBCDIC environment?

>>
>> OK, it seems I have my answer: if('i' + 1 != 'j') we definitely don't

>
> That expression invokes undefined behavior if 'i' equals INT_MAX.


If the character set is either ASCII or EBCDIC, 'i' cannot equal INT_MAX.
If it is not, the check is insufficient anyway.
 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      09-03-2008
On Sep 3, 8:03 am, Harald van Dk <(E-Mail Removed)> wrote:
> On Tue, 02 Sep 2008 21:49:51 -0700, vippstar wrote:
> > On Sep 3, 7:41 am, Pilcrow <(E-Mail Removed)> wrote:
> >> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <(E-Mail Removed)> wrote:
> >> >Is there a way that a proram can detect whether it is operating in an
> >> >ASCII or an EBCDIC environment?

>
> >> OK, it seems I have my answer: if('i' + 1 != 'j') we definitely don't

>
> > That expression invokes undefined behavior if 'i' equals INT_MAX.

>
> If the character set is either ASCII or EBCDIC, 'i' cannot equal INT_MAX.


So? 'i' + 1 still invokes undefined behavior

> If it is not, the check is insufficient anyway.


I agree.
 
Reply With Quote
 
Bartc
Guest
Posts: n/a
 
      09-03-2008

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Sep 3, 7:41 am, Pilcrow <(E-Mail Removed)> wrote:
>> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <(E-Mail Removed)> wrote:
>> >Is there a way that a proram can detect whether it is operating in an
>> >ASCII or an EBCDIC environment?

>>
>> OK, it seems I have my answer: if('i' + 1 != 'j') we definitely don't

>
> That expression invokes undefined behavior if 'i' equals INT_MAX.


If one has to continually worry about a+1 invoking undefined behaviour, then
no line of code is ever going to get written.

Anyway your example should give a compile-time error.

--
Bartc

 
Reply With Quote
 
vippstar@gmail.com
Guest
Posts: n/a
 
      09-03-2008
On Sep 3, 12:15 pm, "Bartc" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > On Sep 3, 7:41 am, Pilcrow <(E-Mail Removed)> wrote:

>
> >> OK, it seems I have my answer: if('i' + 1 != 'j') we definitely don't

>
> > That expression invokes undefined behavior if 'i' equals INT_MAX.

>
> If one has to continually worry about a+1 invoking undefined behaviour, then
> no line of code is ever going to get written.


a+1 no. 'i' + 1 perhaps, and I disagree. There's already many lines of
code written that do not invoke undefined behavior.

> Anyway your example should give a compile-time error.


I know. I have written a correction in a follow-up
Message-ID:
<(E-Mail Removed)>
Unless you are referring to something else.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting end of file for VHDL'93 Gary Thorpe VHDL 2 07-12-2005 07:42 AM
Detecting if Mozilla is Running Peter Firefox 1 04-30-2005 09:47 PM
Detecting edge in a clock synchronous porcess Praveen VHDL 2 04-12-2005 11:36 AM
Detecting of 'U' in a std_logic_vector Thomas Reinemann VHDL 4 11-03-2004 08:24 AM
detecting if program is running under X windows or not Paul Faulstich Perl 1 01-10-2004 07:16 PM



Advertisments