Re: detecting ASCII/EBCDIC

Discussion in 'C Programming' started by vippstar@gmail.com, Sep 3, 2008.

  1. Guest

    On Sep 3, 7:41 am, Pilcrow <> wrote:
    > On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <> 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>
    , Sep 3, 2008
    #1
    1. Advertising

  2. On Tue, 02 Sep 2008 21:49:51 -0700, vippstar wrote:
    > On Sep 3, 7:41 am, Pilcrow <> wrote:
    >> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <> 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.
    Harald van Dijk, Sep 3, 2008
    #2
    1. Advertising

  3. Guest

    On Sep 3, 8:03 am, Harald van D©¦k <> wrote:
    > On Tue, 02 Sep 2008 21:49:51 -0700, vippstar wrote:
    > > On Sep 3, 7:41 am, Pilcrow <> wrote:
    > >> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <> 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.
    , Sep 3, 2008
    #3
  4. Bartc Guest

    <> wrote in message
    news:...
    > On Sep 3, 7:41 am, Pilcrow <> wrote:
    >> On Tue, 02 Sep 2008 15:11:49 -0700, Pilcrow <> 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
    Bartc, Sep 3, 2008
    #4
  5. Guest

    On Sep 3, 12:15 pm, "Bartc" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > On Sep 3, 7:41 am, Pilcrow <> 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:
    <>
    Unless you are referring to something else.
    , Sep 3, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sylvain

    EBCDIC ascii conversion?

    Sylvain, Jun 13, 2004, in forum: Java
    Replies:
    2
    Views:
    21,790
    Thomas Weidenfeller
    Jun 14, 2004
  2. Re: detecting ASCII/EBCDIC

    , Sep 2, 2008, in forum: C Programming
    Replies:
    3
    Views:
    382
  3. Antoninus Twink

    Re: detecting ASCII/EBCDIC

    Antoninus Twink, Sep 2, 2008, in forum: C Programming
    Replies:
    2
    Views:
    327
    Richard
    Sep 3, 2008
  4. Keith Thompson

    Re: detecting ASCII/EBCDIC

    Keith Thompson, Sep 3, 2008, in forum: C Programming
    Replies:
    2
    Views:
    323
    Keith Thompson
    Sep 3, 2008
  5. Jean-Marc Bourguet

    Re: detecting ASCII/EBCDIC

    Jean-Marc Bourguet, Sep 3, 2008, in forum: C Programming
    Replies:
    7
    Views:
    423
    osmium
    Sep 4, 2008
Loading...

Share This Page