Re: detecting ASCII/EBCDIC

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

  1. Guest

    On Sep 3, 1:11 am, Pilcrow <> wrote:
    > Is there a way that a proram can detect whether it is operating in an
    > ASCII or an EBCDIC environment?



    No.
    But you can check if a certain symbol has been mapped to the same
    value as ASCII/EBCDIC:

    #if 'A' == 65
    /* A is mapped to the same value as ASCII */
    #elif
    /* A is not mapped to the same value as ASCII */
    #endif

    That's not telling you much though.
    , Sep 2, 2008
    #1
    1. Advertising

  2. Guest

    On Sep 3, 1:22 am, wrote:
    > On Sep 3, 1:11 am, Pilcrow <> wrote:
    >
    > > Is there a way that a proram can detect whether it is operating in an
    > > ASCII or an EBCDIC environment?

    >
    > No.
    > But you can check if a certain symbol has been mapped to the same
    > value as ASCII/EBCDIC:
    >
    > #if 'A' == 65
    > /* A is mapped to the same value as ASCII */
    > #elif

    ^^^^
    That should've been 'else'.
    , Sep 2, 2008
    #2
    1. Advertising

  3. Ben Pfaff Guest

    writes:

    > But you can check if a certain symbol has been mapped to the same
    > value as ASCII/EBCDIC:
    >
    > #if 'A' == 65
    > /* A is mapped to the same value as ASCII */
    > #elif
    > /* A is not mapped to the same value as ASCII */
    > #endif


    I don't think that's guaranteed to work, because preprocessor
    directives are interpreted in the source character set, which may
    differ arbitrarily from the execution character set. It could be
    the case that the source character set is ASCII and the execution
    character set is EBCDIC, as far as I know.
    --
    char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
    ={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
    =b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
    2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
    Ben Pfaff, Sep 3, 2008
    #3
  4. Guest

    On Sep 3, 2:09 am, Ben Pfaff <> wrote:
    > writes:
    > > But you can check if a certain symbol has been mapped to the same
    > > value as ASCII/EBCDIC:

    >
    > > #if 'A' == 65
    > > /* A is mapped to the same value as ASCII */
    > > #elif
    > > /* A is not mapped to the same value as ASCII */
    > > #endif

    >
    > I don't think that's guaranteed to work, because preprocessor
    > directives are interpreted in the source character set, which may
    > differ arbitrarily from the execution character set. It could be
    > the case that the source character set is ASCII and the execution
    > character set is EBCDIC, as far as I know.


    Ah - I did not think of that. Then perhaps change it to `if'.

    if('A' == 65) { ... }
    , Sep 3, 2008
    #4
    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,819
    Thomas Weidenfeller
    Jun 14, 2004
  2. Antoninus Twink

    Re: detecting ASCII/EBCDIC

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

    Re: detecting ASCII/EBCDIC

    Keith Thompson, Sep 3, 2008, in forum: C Programming
    Replies:
    2
    Views:
    325
    Keith Thompson
    Sep 3, 2008
  4. Re: detecting ASCII/EBCDIC

    , Sep 3, 2008, in forum: C Programming
    Replies:
    4
    Views:
    379
  5. Jean-Marc Bourguet

    Re: detecting ASCII/EBCDIC

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

Share This Page